diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-08-06 12:33:16 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-08-06 12:33:16 +0200 |
commit | 0dea9c7cf9820b43bf04810996cf8d732a4e0ee0 (patch) | |
tree | 61179febedc33f493abd17ca088d00e4a65de897 /arch/ppc | |
parent | e188d2ec26e8cf6d4ba0908e76868e91b6999fdf (diff) | |
parent | 8e04a039a9625f75cdc9274ad06c4b8084565848 (diff) | |
download | barebox-0dea9c7cf9820b43bf04810996cf8d732a4e0ee0.tar.gz barebox-0dea9c7cf9820b43bf04810996cf8d732a4e0ee0.tar.xz |
Merge branch 'for-next/ppc'
Diffstat (limited to 'arch/ppc')
-rw-r--r-- | arch/ppc/boards/pcm030/Makefile | 2 | ||||
-rw-r--r-- | arch/ppc/boards/pcm030/config.h | 11 | ||||
-rw-r--r-- | arch/ppc/boards/pcm030/eeprom.c | 118 | ||||
-rw-r--r-- | arch/ppc/boards/pcm030/pcm030.c | 22 | ||||
-rw-r--r-- | arch/ppc/configs/pcm030_defconfig | 3 | ||||
-rw-r--r-- | arch/ppc/mach-mpc5xxx/cpu.c | 2 | ||||
-rw-r--r-- | arch/ppc/mach-mpc5xxx/include/mach/clock.h (renamed from arch/ppc/mach-mpc5xxx/include/mach/clocks.h) | 4 | ||||
-rw-r--r-- | arch/ppc/mach-mpc5xxx/time.c | 2 |
8 files changed, 150 insertions, 14 deletions
diff --git a/arch/ppc/boards/pcm030/Makefile b/arch/ppc/boards/pcm030/Makefile index e7d744bfb4..4e5dc4f57b 100644 --- a/arch/ppc/boards/pcm030/Makefile +++ b/arch/ppc/boards/pcm030/Makefile @@ -1,2 +1,2 @@ -obj-y += pcm030.o +obj-y += pcm030.o eeprom.o extra-y += barebox.lds diff --git a/arch/ppc/boards/pcm030/config.h b/arch/ppc/boards/pcm030/config.h index 6e74964056..3fe1f286d9 100644 --- a/arch/ppc/boards/pcm030/config.h +++ b/arch/ppc/boards/pcm030/config.h @@ -25,18 +25,9 @@ #include <mach/mpc5xxx.h> -#define CFG_MPC5XXX_CLKIN 33333333 /* ... running at 33.333333MHz */ - -#define CFG_GPS_PORT_CONFIG 0x00558c10 /* PSC6=UART, PSC3=UART ; Ether=100MBit with MD */ +#define CFG_MPC5XXX_CLKIN 33333000 /* ... running at 33.333MHz */ #define CFG_HID0_INIT HID0_ICE | HID0_ICFI #define CFG_HID0_FINAL HID0_ICE - -#define CFG_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */ - -#define OF_CPU "PowerPC,5200@0" -#define OF_TBCLK CFG_MPC5XXX_CLKIN -#define OF_SOC "soc5200@f0000000" - #endif /* __CONFIG_H */ diff --git a/arch/ppc/boards/pcm030/eeprom.c b/arch/ppc/boards/pcm030/eeprom.c new file mode 100644 index 0000000000..aa00f361cd --- /dev/null +++ b/arch/ppc/boards/pcm030/eeprom.c @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2015 Juergen Borleis <kernel@pengutronix.de> + * + * Based on code from: + * Copyright (C) 2013 Jan Luebbe <j.luebbe@pengutronix.de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include <common.h> +#include <errno.h> +#include <fcntl.h> +#include <fs.h> +#include <globalvar.h> +#include <xfuncs.h> +#include <init.h> +#include <net.h> + +#define PCM030_EEPROM_DEVICE "/dev/eeprom0" + +/* + * The first 2048 bytes contain the U-Boot environment shipped with the boards. + * After that an area begins where some board specific and partially unique data + * is stored. All of this data is plain test, string delimiter is the semicolon. + * the last string terminates with a '\0'. + * One example found in the 'product' area: PCM-030-02REI;017822;0050C2875974\0 + * The first string seems to be the product type, the second string some kind + * of serial number and the last string the boards unique MAC. + */ +struct pcm030_eeprom { + char env[0x800]; /* u-boot environment */ + char product[0x80]; /* <product>;<serno>;<mac>\0 */ +} __attribute__((packed)); + +static void pcm030_read_factory_data(const struct pcm030_eeprom *buf) +{ + unsigned u, l; + char *board, *serial; + char *full_mac = "xx:xx:xx:xx:xx:xx"; + u8 enetaddr[6]; + + u = 0; + + for (l = 0; (l + u) < sizeof(buf->product); l++) { + if (buf->product[u + l] != ';') + continue; + board = xstrndup(&buf->product[u], l); + u += l + 1; + globalvar_add_simple("model.type", board); + free(board); + } + + for (l = 0; (l + u) < sizeof(buf->product); l++) { + if (buf->product[u + l] != ';') + continue; + serial = xstrndup(&buf->product[u], l); + u += l + 1; + globalvar_add_simple("model.serial", serial); + free(serial); + } + + /* for the MAC do a simple duck test */ + if (buf->product[u] != ';' && buf->product[u + 12] == '\0') { + full_mac[0] = buf->product[u + 0]; + full_mac[1] = buf->product[u + 1]; + full_mac[3] = buf->product[u + 2]; + full_mac[4] = buf->product[u + 3]; + full_mac[6] = buf->product[u + 4]; + full_mac[7] = buf->product[u + 5]; + full_mac[9] = buf->product[u + 6]; + full_mac[10] = buf->product[u + 7]; + full_mac[12] = buf->product[u + 8]; + full_mac[13] = buf->product[u + 9]; + full_mac[15] = buf->product[u + 10]; + full_mac[16] = buf->product[u + 11]; + string_to_ethaddr(full_mac, enetaddr); + eth_register_ethaddr(0, enetaddr); + return; + } + + printf("EEPROM contains no ethernet MAC\n"); +} + +static int pcm030_eeprom_read(void) +{ + int fd, ret; + struct pcm030_eeprom *buf; + + fd = open(PCM030_EEPROM_DEVICE, O_RDONLY); + if (fd < 0) { + perror("failed to open " PCM030_EEPROM_DEVICE); + return fd; + } + + buf = xmalloc(sizeof(struct pcm030_eeprom)); + + ret = pread(fd, buf, sizeof(struct pcm030_eeprom), 0); + if (ret < sizeof(struct pcm030_eeprom)) { + perror("failed to read " PCM030_EEPROM_DEVICE); + goto out; + } + + pcm030_read_factory_data(buf); + ret = 0; +out: + free(buf); + close(fd); + + return ret; +} +late_initcall(pcm030_eeprom_read); diff --git a/arch/ppc/boards/pcm030/pcm030.c b/arch/ppc/boards/pcm030/pcm030.c index a7fa21d173..11b3beb20f 100644 --- a/arch/ppc/boards/pcm030/pcm030.c +++ b/arch/ppc/boards/pcm030/pcm030.c @@ -32,12 +32,23 @@ #include <memory.h> #include <linux/sizes.h> #include <linux/stat.h> +#include <asm/io.h> #include <fs.h> +#include <i2c/i2c.h> static struct fec_platform_data fec_info = { .xcv_type = PHY_INTERFACE_MODE_MII, }; +static struct i2c_board_info pcm030_i2c_devices[] = { + { I2C_BOARD_INFO("pcf8563", 0x51), }, + { I2C_BOARD_INFO("24c32", 0x52), }, +}; + +struct i2c_platform_data pcm030_i2c_plat = { + .bitrate = 100000, +}; + static int devices_init (void) { struct stat s; @@ -52,6 +63,9 @@ static int devices_init (void) add_generic_device("fec_mpc5xxx", DEVICE_ID_DYNAMIC, NULL, MPC5XXX_FEC, 0x200, IORESOURCE_MEM, &fec_info); + i2c_register_board_info(0, pcm030_i2c_devices, ARRAY_SIZE(pcm030_i2c_devices)); + add_generic_device("i2c-fsl", DEVICE_ID_DYNAMIC, NULL, MPC5XXX_I2C2, 0x100, + IORESOURCE_MEM, &pcm030_i2c_plat); ret = stat("/dev/nor0", &s); if (ret) @@ -141,10 +155,16 @@ void initdram (int board_type) /* Setup pin multiplexing */ /* PSC6=UART, PSC3=UART ; Ether=100MBit with MD */ - *(vu_long *)MPC5XXX_GPS_PORT_CONFIG = 0x00558c10; + *(vu_long *)MPC5XXX_GPS_PORT_CONFIG = 0x00559c10; *(vu_long *)MPC5XXX_CS_BURST = 0x00000000; *(vu_long *)MPC5XXX_CS_DEADCYCLE = 0x33333333; + /* + * Make USB work due to the special base crystal frequency: + * 33,3330MHz * 16 = 533,328MHz main clock, but should be 528 MHz Clock + */ + out_be32((void *)MPC5XXX_CDM_48_FDC, 0x00015555); + mpc5200_setup_bus_clocks(1, 4); if (get_pc() > SZ_128M) { diff --git a/arch/ppc/configs/pcm030_defconfig b/arch/ppc/configs/pcm030_defconfig index 7b84e2f3b6..61380ac294 100644 --- a/arch/ppc/configs/pcm030_defconfig +++ b/arch/ppc/configs/pcm030_defconfig @@ -35,8 +35,11 @@ CONFIG_CMD_OFTREE=y CONFIG_CMD_TIME=y CONFIG_NET=y CONFIG_DRIVER_NET_MPC5200=y +CONFIG_I2C=y +CONFIG_I2C_IMX=y CONFIG_MTD=y CONFIG_DRIVER_CFI=y CONFIG_CFI_BUFFER_WRITE=y +CONFIG_EEPROM_AT24=y CONFIG_FS_TFTP=y CONFIG_ZLIB=y diff --git a/arch/ppc/mach-mpc5xxx/cpu.c b/arch/ppc/mach-mpc5xxx/cpu.c index a53af63039..3f826e4994 100644 --- a/arch/ppc/mach-mpc5xxx/cpu.c +++ b/arch/ppc/mach-mpc5xxx/cpu.c @@ -31,7 +31,7 @@ #include <types.h> #include <errno.h> #include <of.h> -#include <mach/clocks.h> +#include <mach/clock.h> int checkcpu (void) { diff --git a/arch/ppc/mach-mpc5xxx/include/mach/clocks.h b/arch/ppc/mach-mpc5xxx/include/mach/clock.h index 4e1a903e79..b19686f18c 100644 --- a/arch/ppc/mach-mpc5xxx/include/mach/clocks.h +++ b/arch/ppc/mach-mpc5xxx/include/mach/clock.h @@ -6,5 +6,9 @@ unsigned long get_cpu_clock(void); unsigned long get_ipb_clock(void); unsigned long get_pci_clock(void); unsigned long get_timebase_clock(void); +static inline unsigned long fsl_get_i2c_freq(void) +{ + return get_ipb_clock(); +} #endif /* __ASM_ARCH_CLOCKS_H */ diff --git a/arch/ppc/mach-mpc5xxx/time.c b/arch/ppc/mach-mpc5xxx/time.c index 699a66dff4..aaa4573f6f 100644 --- a/arch/ppc/mach-mpc5xxx/time.c +++ b/arch/ppc/mach-mpc5xxx/time.c @@ -20,7 +20,7 @@ #include <common.h> #include <clock.h> #include <init.h> -#include <mach/clocks.h> +#include <mach/clock.h> #include <asm/common.h> uint64_t ppc_clocksource_read(void) |