diff options
Diffstat (limited to 'board/keymile/common')
-rw-r--r-- | board/keymile/common/common.c | 29 | ||||
-rw-r--r-- | board/keymile/common/common.h | 5 | ||||
-rw-r--r-- | board/keymile/common/ivm.c | 5 | ||||
-rw-r--r-- | board/keymile/common/qrio.c | 19 | ||||
-rw-r--r-- | board/keymile/common/qrio.h | 1 |
5 files changed, 37 insertions, 22 deletions
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index df507e27907..9c482d8454e 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -41,7 +41,6 @@ DECLARE_GLOBAL_DATA_PTR; */ int set_km_env(void) { - uchar buf[32]; unsigned int pnvramaddr; unsigned int pram; unsigned int varaddr; @@ -49,10 +48,9 @@ int set_km_env(void) char *p; unsigned long rootfssize = 0; - pnvramaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM - - CONFIG_KM_PNVRAM; - sprintf((char *)buf, "0x%x", pnvramaddr); - env_set("pnvramaddr", (char *)buf); + pnvramaddr = CONFIG_SYS_SDRAM_BASE + gd->ram_size - + CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM - CONFIG_KM_PNVRAM; + env_set_hex("pnvramaddr", pnvramaddr); /* try to read rootfssize (ram image) from environment */ p = env_get("rootfssize"); @@ -60,16 +58,14 @@ int set_km_env(void) strict_strtoul(p, 16, &rootfssize); pram = (rootfssize + CONFIG_KM_RESERVED_PRAM + CONFIG_KM_PHRAM + CONFIG_KM_PNVRAM) / 0x400; - sprintf((char *)buf, "0x%x", pram); - env_set("pram", (char *)buf); + env_set_ulong("pram", pram); - varaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM; - sprintf((char *)buf, "0x%x", varaddr); - env_set("varaddr", (char *)buf); + varaddr = CONFIG_SYS_SDRAM_BASE + gd->ram_size - + CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM; + env_set_hex("varaddr", varaddr); kernelmem = gd->ram_size - 0x400 * pram; - sprintf((char *)buf, "0x%x", kernelmem); - env_set("kernelmem", (char *)buf); + env_set_hex("kernelmem", kernelmem); return 0; } @@ -243,7 +239,6 @@ static int do_checkboardidhwk(struct cmd_tbl *cmdtp, int flag, int argc, p = env_get("hwkey"); if (p) rc = strict_strtoul(p, 16, &envhwkey); - if (rc != 0) { printf("strict_strtoul returns error: %d", rc); return rc; @@ -305,15 +300,11 @@ static int do_checkboardidhwk(struct cmd_tbl *cmdtp, int flag, int argc, * set the values in environment variables. */ if (bid == ivmbid && hwkey == ivmhwkey) { - char buf[10]; - found = 1; envbid = bid; envhwkey = hwkey; - sprintf(buf, "%lx", bid); - env_set("boardid", buf); - sprintf(buf, "%lx", hwkey); - env_set("hwkey", buf); + env_set_hex("boardid", bid); + env_set_hex("hwkey", hwkey); } } /* end while( ! found ) */ } diff --git a/board/keymile/common/common.h b/board/keymile/common/common.h index 8251de4db8f..15a3c3797d1 100644 --- a/board/keymile/common/common.h +++ b/board/keymile/common/common.h @@ -136,6 +136,11 @@ int set_km_env(void); #define DELAY_ABORT_SEQ 62 /* @200kHz 9 clocks = 44us, 62us is ok */ #define DELAY_HALF_PERIOD (500 / (CONFIG_SYS_I2C_SPEED / 1000)) +void set_sda(int state); +void set_scl(int state); +int get_sda(void); +int get_scl(void); + int i2c_soft_read_pin(void); int i2c_make_abort(void); #endif /* __KEYMILE_COMMON_H */ diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c index e989bf609fe..bc8ffd56e1c 100644 --- a/board/keymile/common/ivm.c +++ b/board/keymile/common/ivm.c @@ -321,6 +321,11 @@ static int ivm_populate_env(unsigned char *buf, int len, int mac_address_offset) process_mac(valbuf, page2, mac_address_offset, true); env_set((char *)"eth1addr", (char *)valbuf); } + if (IS_ENABLED(CONFIG_TARGET_KMCENT2)) { + /* 3rd ethernet interface */ + process_mac(valbuf, page2, 2, true); + env_set((char *)"eth4addr", (char *)valbuf); + } return 0; } diff --git a/board/keymile/common/qrio.c b/board/keymile/common/qrio.c index 06a4e67881f..25937ee362f 100644 --- a/board/keymile/common/qrio.c +++ b/board/keymile/common/qrio.c @@ -5,15 +5,28 @@ */ #include <common.h> +#include <asm/io.h> #include <linux/bitops.h> #include "common.h" #include "qrio.h" +/* QRIO ID register offset */ +#define ID_REV_OFF 0x00 + /* QRIO GPIO register offsets */ #define DIRECT_OFF 0x18 #define GPRT_OFF 0x1c +void show_qrio(void) +{ + void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE; + u16 id_rev = in_be16(qrio_base + ID_REV_OFF); + + printf("QRIO: id = %u, revision = %u\n", + (id_rev >> 8) & 0xff, id_rev & 0xff); +} + int qrio_get_gpio(u8 port_off, u8 gpio_nr) { u32 gprt; @@ -129,7 +142,7 @@ void qrio_prst(u8 bit, bool en, bool wden) void qrio_prstcfg(u8 bit, u8 mode) { - u32 prstcfg; + unsigned long prstcfg; u8 i; void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE; @@ -137,9 +150,9 @@ void qrio_prstcfg(u8 bit, u8 mode) for (i = 0; i < 2; i++) { if (mode & (1 << i)) - set_bit(2 * bit + i, &prstcfg); + __set_bit(2 * bit + i, &prstcfg); else - clear_bit(2 * bit + i, &prstcfg); + __clear_bit(2 * bit + i, &prstcfg); } out_be32(qrio_base + PRSTCFG_OFF, prstcfg); diff --git a/board/keymile/common/qrio.h b/board/keymile/common/qrio.h index a04a73266fb..757bcbf2f3d 100644 --- a/board/keymile/common/qrio.h +++ b/board/keymile/common/qrio.h @@ -11,6 +11,7 @@ #define QRIO_GPIO_A 0x40 #define QRIO_GPIO_B 0x60 +void show_qrio(void); int qrio_get_gpio(u8 port_off, u8 gpio_nr); void qrio_set_opendrain_gpio(u8 port_off, u8 gpio_nr, u8 val); void qrio_set_gpio(u8 port_off, u8 gpio_nr, bool value); |