As all the IIC controllers on system uses the same 'iichb' prefix we cannot
rely only on checking the device unit to indentify the BSC unit we are attaching to. Make use of the device base address to identify our BSC unit. Approved by: adrian (mentor)
This commit is contained in:
parent
8ce07fe72e
commit
21cb1342c0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=258045
@ -234,31 +234,13 @@ static int
|
||||
bcm_bsc_attach(device_t dev)
|
||||
{
|
||||
struct bcm_bsc_softc *sc;
|
||||
unsigned long start;
|
||||
device_t gpio;
|
||||
int rid;
|
||||
|
||||
if (device_get_unit(dev) > 1) {
|
||||
device_printf(dev, "only bsc0 and bsc1 are supported\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
int i, rid;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
sc->sc_dev = dev;
|
||||
|
||||
/*
|
||||
* Configure the GPIO pins to ALT0 function to enable BSC control
|
||||
* over the pins.
|
||||
*/
|
||||
gpio = devclass_get_device(devclass_find("gpio"), 0);
|
||||
if (!gpio) {
|
||||
device_printf(dev, "cannot find gpio0\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
bcm_gpio_set_alternate(gpio, bcm_bsc_pins[device_get_unit(dev)].sda,
|
||||
BCM_GPIO_ALT0);
|
||||
bcm_gpio_set_alternate(gpio, bcm_bsc_pins[device_get_unit(dev)].scl,
|
||||
BCM_GPIO_ALT0);
|
||||
|
||||
rid = 0;
|
||||
sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
|
||||
RF_ACTIVE);
|
||||
@ -270,6 +252,29 @@ bcm_bsc_attach(device_t dev)
|
||||
sc->sc_bst = rman_get_bustag(sc->sc_mem_res);
|
||||
sc->sc_bsh = rman_get_bushandle(sc->sc_mem_res);
|
||||
|
||||
/* Check the unit we are attaching by its base address. */
|
||||
start = rman_get_start(sc->sc_mem_res);
|
||||
for (i = 0; i < nitems(bcm_bsc_pins); i++) {
|
||||
if (bcm_bsc_pins[i].start == start)
|
||||
break;
|
||||
}
|
||||
if (i == nitems(bcm_bsc_pins)) {
|
||||
device_printf(dev, "only bsc0 and bsc1 are supported\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
/*
|
||||
* Configure the GPIO pins to ALT0 function to enable BSC control
|
||||
* over the pins.
|
||||
*/
|
||||
gpio = devclass_get_device(devclass_find("gpio"), 0);
|
||||
if (!gpio) {
|
||||
device_printf(dev, "cannot find gpio0\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
bcm_gpio_set_alternate(gpio, bcm_bsc_pins[i].sda, BCM_GPIO_ALT0);
|
||||
bcm_gpio_set_alternate(gpio, bcm_bsc_pins[i].scl, BCM_GPIO_ALT0);
|
||||
|
||||
rid = 0;
|
||||
sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
|
||||
RF_ACTIVE | RF_SHAREABLE);
|
||||
|
@ -33,9 +33,10 @@
|
||||
struct {
|
||||
uint32_t sda;
|
||||
uint32_t scl;
|
||||
unsigned long start;
|
||||
} bcm_bsc_pins[] = {
|
||||
{ 0, 1 }, /* BSC0 GPIO pins. */
|
||||
{ 2, 3 } /* BSC1 GPIO pins. */
|
||||
{ 0, 1, 0x20205000 }, /* BSC0 GPIO pins and base address. */
|
||||
{ 2, 3, 0x20804000 } /* BSC1 GPIO pins and base address. */
|
||||
};
|
||||
|
||||
struct bcm_bsc_softc {
|
||||
|
Loading…
Reference in New Issue
Block a user