diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c index f263f84..2f3b145 100644 --- a/arch/arm/mach-omap2/board-am335xevm.c +++ b/arch/arm/mach-omap2/board-am335xevm.c @@ -335,6 +335,30 @@ struct am335x_eeprom_config1 { u8 cpld_ver[8]; }; +/* + * These two struct are Beaglbone Cape EEPROM data, + * see SRM for Beaglebone + */ +struct bbone_cape_eeprom_pin_usage { + u8 mask[2]; +} __attribute__((__packed__)); + +struct bbone_cape_eeprom_data { + u32 header; + u8 eeprom_rev[2]; + u8 name[32]; + char version[4]; + u8 manufctr[16]; + u8 part_nr[16]; + u8 nbr_of_pins[2]; + u8 serial[12]; + struct bbone_cape_eeprom_pin_usage pin_usage[74]; + u8 vdd_3v3_cur[2]; + u8 vdd_5_cur[2]; + u8 sys_5_cur[2]; + u8 dc_supplied[2]; +} __attribute__((__packed__)); + static struct am335x_evm_eeprom_config config; static struct am335x_eeprom_config1 config1; static bool daughter_brd_detected; @@ -662,6 +686,12 @@ static struct pinmux_config d_can_gp_pin_mux[] = { {NULL, 0}, }; +static struct pinmux_config d_can_bbone_pin_mux[] = { + {"uart1_rxd.d_can1_tx", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL}, + {"uart1_txd.d_can1_rx", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLUP}, + {NULL, 0}, +}; + static struct pinmux_config d_can_ia_pin_mux[] = { {"uart0_rxd.d_can0_tx", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL}, {"uart0_txd.d_can0_rx", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLUP}, @@ -1584,11 +1614,82 @@ static void i2c1_init(int evm_id, int profile) return; } -static struct i2c_board_info am335x_i2c2_boardinfo[] = { -}; +/* Here daughterboards on Beaglebone (cape's) are detected + */ +static void am335x_setup_bbone_cape_board(struct memory_accessor *m, void *c) +{ + static int capes_scanned=0; + int ret; + struct bbone_cape_eeprom_data *cape_eeprom_data = + (struct bbone_cape_eeprom_data *)c; + + /* + * Read from the EEPROM to see the presence of daughter board. + * If present, print the cpld version. + */ + + ret = m->read(m, (char *)cape_eeprom_data, 0, + sizeof(struct bbone_cape_eeprom_data)); + if (ret == sizeof(struct bbone_cape_eeprom_data)) { + char printable_name[sizeof(cape_eeprom_data->name)]; + size_t i=0; + + for(;;) { + if( i == (sizeof(cape_eeprom_data->name) -1 ) || + cape_eeprom_data->name[i] == '.' ) { + printable_name[i] = 0; + break; + } + printable_name[i]=cape_eeprom_data->name[i]; + i++; + } + + pr_info("Cape detected, %s",printable_name); + daughter_brd_detected = true; + if(!strncmp(cape_eeprom_data->name, "BeagleBone CANBUS CAPE", 22)) { + /* There are two (?) can interfaces on + * the Beaglebone baseboard, but we only initialize one of + * them, so if two CANbus capes are connected something must + * be done here. Further we cannot say for sure which pins + * in the mux this can interface should be pinned out to. + * It depends on jumpers on the CANbus cape. But default + * is the pins named UART1_RXD and UART1_TXD + */ + static int canbus_capes_detected = 0; + + if(canbus_capes_detected++ == 0) { + setup_pin_mux(d_can_bbone_pin_mux); + am33xx_d_can_init(1); + } else + pr_info("More than one CANbus cape detected, " + "but only one interface will be initialized"); + } + } + if(++capes_scanned == BBONE_MAX_CAPES && daughter_brd_detected == false) + pr_info("No cape found"); +} + +static struct bbone_cape_eeprom_data cape_eeprom_data[BBONE_MAX_CAPES]; + +static struct at24_platform_data am335x_bbone_cape_board_eeprom_info[BBONE_MAX_CAPES]; + +static struct i2c_board_info am335x_i2c2_boardinfo[BBONE_MAX_CAPES]; static void i2c2_init(int evm_id, int profile) { + int i; + + for(i=0;i