FreeBSD/sys/arm/at91/board_tsc4370.c
/*
 * TSC-specific code to read the ID eeprom on the mainboard and extract the
 * unit's EUI-64 which gets translated into a MAC-48 for ethernet.
 */
TSC-specific code to read the ID eeprom on the mainboard and extract the
unit's EUI-64 which gets translated into a MAC-48 for ethernet.
TSC - specific code to read the ID eeprom on the mainboard and extract the unit ' s EUI - 64 which gets translated into a MAC - 48 for ethernet .
static void
eeprom_init(void)
{
	const uint32_t twiHz    = 400000;
	const uint32_t twiCkDiv = 1 << 16;
	const uint32_t twiChDiv = ((at91_master_clock / twiHz) - 2) << 8;
	const uint32_t twiClDiv = ((at91_master_clock / twiHz) - 2);
	at91_pio_use_periph_a(AT91RM92_PIOA_BASE,
	    AT91C_PIO_PA25 | AT91C_PIO_PA26, 0);
	at91_pio_gpio_high_z(AT91RM92_PIOA_BASE, AT91C_PIO_PA25, 1);
	WR4HW(AT91RM92_PMC_BASE, PMC_PCER, 1u << AT91RM92_IRQ_TWI);
	WR4HW(AT91RM92_TWI_BASE, TWI_IDR, 0xffffffff);
	WR4HW(AT91RM92_TWI_BASE, TWI_CR, TWI_CR_SWRST);
	WR4HW(AT91RM92_TWI_BASE, TWI_CR, TWI_CR_MSEN | TWI_CR_SVDIS);
	WR4HW(AT91RM92_TWI_BASE, TWI_CWGR, twiCkDiv | twiChDiv | twiClDiv);
}
static void eeprom_init ( void ) { const uint32_t twiHz = 400000 ; const uint32_t twiCkDiv = 1 << 16 ; const uint32_t twiChDiv = ( ( at91_master_clock / twiHz ) - 2 ) << 8 ; const uint32_t twiClDiv = ( ( at91_master_clock / twiHz ) - 2 ) ; at91_pio_use_periph_a ( AT91RM92_PIOA_BASE , AT91C_PIO_PA25 | AT91C_PIO_PA26 , 0 ) ; at91_pio_gpio_high_z ( AT91RM92_PIOA_BASE , AT91C_PIO_PA25 , 1 ) ; WR4HW ( AT91RM92_PMC_BASE , PMC_PCER , 1u << AT91RM92_IRQ_TWI ) ; WR4HW ( AT91RM92_TWI_BASE , TWI_IDR , 0xffffffff ) ; WR4HW ( AT91RM92_TWI_BASE , TWI_CR , TWI_CR_SWRST ) ; WR4HW ( AT91RM92_TWI_BASE , TWI_CR , TWI_CR_MSEN | TWI_CR_SVDIS ) ; WR4HW ( AT91RM92_TWI_BASE , TWI_CWGR , twiCkDiv | twiChDiv | twiClDiv ) ; }
TSC-specific code to read the ID eeprom on the mainboard and extract the
 unit's EUI-64 which gets translated into a MAC-48 for ethernet.
TSC - specific code to read the ID eeprom on the mainboard and extract the unit ' s EUI - 64 which gets translated into a MAC - 48 for ethernet .
/*
	 * Set the TWCK and TWD lines for Periph A, no pullup, open-drain.
	 */ /*
	 * Enable TWI power (irq numbers are also device IDs for power)
	 */ /*
	 * Disable TWI interrupts, reset device, enable Master mode,
	 * disable Slave mode, set the clock.
	 */