void do_board_detect(void) { /* Ensure I2C is initialized for EEPROM access*/ gpi2c_init(); if (ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS, CONFIG_EEPROM_CHIP_ADDRESS)) printf("ti_i2c_eeprom_init failed\n"); }
static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, u32 header, u32 size, uint8_t *ep) { u32 byte, hdr_read; int rc; gpi2c_init(); rc = ti_i2c_eeprom_init(bus_addr, dev_addr); if (rc) return rc; /* * Read the header first then only read the other contents. */ byte = 2; rc = ti_i2c_set_alen(bus_addr, dev_addr, byte); if (rc) return rc; rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4); if (rc) return rc; /* Corrupted data??? */ if (hdr_read != header) { rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4); /* * read the eeprom header using i2c again, but use only a * 1 byte address (some legacy boards need this..) */ byte = 1; if (rc) { rc = ti_i2c_set_alen(bus_addr, dev_addr, byte); if (rc) return rc; rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4); } if (rc) return rc; } if (hdr_read != header) return -1; rc = i2c_read(dev_addr, 0x0, byte, ep, size); if (rc) return rc; return 0; }
void scale_vcores(void) { const struct dpll_params *mpu_params; /* Ensure I2C is initialized for PMIC configuration */ gpi2c_init(); /* Get the frequency */ mpu_params = get_dpll_mpu_params(); if (board_is_idk()) scale_vcores_idk(mpu_params->m); else scale_vcores_generic(mpu_params->m); }
int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr, struct ti_am_eeprom **epp) { int rc; struct ti_am_eeprom *ep; if (!epp) return -1; ep = TI_AM_EEPROM_DATA; if (ep->header == TI_EEPROM_HEADER_MAGIC) goto already_read; /* Initialize with a known bad marker for i2c fails.. */ ep->header = 0xADEAD12C; gpi2c_init(); rc = ti_i2c_eeprom_init(bus_addr, dev_addr); if (rc) return rc; rc = i2c_read(dev_addr, 0x0, 2, (uint8_t *)ep, sizeof(*ep)); if (rc) return rc; /* Corrupted data??? */ if (ep->header != TI_EEPROM_HEADER_MAGIC) { rc = i2c_read(dev_addr, 0x0, 2, (uint8_t *)ep, sizeof(*ep)); /* * read the eeprom using i2c again, but use only a 1 byte * address (some legacy boards need this..) */ if (rc) rc = i2c_read(dev_addr, 0x0, 1, (uint8_t *)ep, sizeof(*ep)); if (rc) return rc; } #ifdef CONFIG_BOARD_SOM_PH8800 strcpy(ep->name, "SOM-PH88"); #endif #ifdef CONFIG_BOARD_SOM_PH8700 strcpy(ep->name, "SOM-PH87"); #endif #ifdef CONFIG_BOARD_SBC_EC8800 strcpy(ep->name, "SBC-EC88"); #endif if (ep->header != TI_EEPROM_HEADER_MAGIC){ /* * strcpy(ep->name, "SOM-PH8700"); * ep->header = TI_EEPROM_HEADER_MAGIC; * * Temporary configuration, because PH8700 eeprom is empty now; * If the eeprom written content in the future ,please delete them; */ //strcpy(ep->name, "SOM-PH8700"); #if defined CONFIG_BOARD_SOM_PH8800 || defined CONFIG_BOARD_SOM_PH8700 || defined CONFIG_BOARD_SBC_EC8800 ep->header = TI_EEPROM_HEADER_MAGIC; #endif /*return -1;*/ } already_read: *epp = ep; return 0; }