static inline struct gpio_bank *get_gpio_bank(int gpio) { if (cpu_is_omap15xx()) { if (OMAP_GPIO_IS_MPUIO(gpio)) return &gpio_bank[0]; return &gpio_bank[1]; } else if (cpu_is_omap16xx()) { if (OMAP_GPIO_IS_MPUIO(gpio)) return &gpio_bank[0]; return &gpio_bank[1 + (gpio >> 4)]; } else if (cpu_is_omap7xx()) {
int __init cbus_bus_init(void) { struct cbus_host *chost; int ret; chost = kmalloc(sizeof (*chost), GFP_KERNEL); if (chost == NULL) return -ENOMEM; memset(chost, 0, sizeof (*chost)); spin_lock_init(&chost->lock); /* REVISIT: Pass these from board-*.c files in platform_data */ if (machine_is_nokia770()) { chost->clk_gpio = OMAP_MPUIO(11); chost->dat_gpio = OMAP_MPUIO(10); chost->sel_gpio = OMAP_MPUIO(9); } else if (machine_is_nokia_n800() || machine_is_nokia_n810() || machine_is_nokia_n810_wimax()) { chost->clk_gpio = 66; chost->dat_gpio = 65; chost->sel_gpio = 64; } else { printk(KERN_ERR "cbus: Unsupported board\n"); ret = -ENODEV; goto exit1; } #ifdef CONFIG_ARCH_OMAP1 if (!OMAP_GPIO_IS_MPUIO(chost->clk_gpio) || !OMAP_GPIO_IS_MPUIO(chost->dat_gpio) || !OMAP_GPIO_IS_MPUIO(chost->sel_gpio)) { printk(KERN_ERR "cbus: Only MPUIO pins supported\n"); ret = -ENODEV; goto exit1; } #endif if ((ret = gpio_request(chost->clk_gpio, "CBUS clk")) < 0) goto exit1; if ((ret = gpio_request(chost->dat_gpio, "CBUS data")) < 0) goto exit2; if ((ret = gpio_request(chost->sel_gpio, "CBUS sel")) < 0) goto exit3; gpio_direction_output(chost->clk_gpio, 0); gpio_direction_input(chost->dat_gpio); gpio_direction_output(chost->sel_gpio, 1); gpio_set_value(chost->clk_gpio, 1); gpio_set_value(chost->clk_gpio, 0); cbus_host = chost; return 0; exit3: gpio_free(chost->dat_gpio); exit2: gpio_free(chost->clk_gpio); exit1: kfree(chost); return ret; }
int __init cbus_bus_init(void) { const struct omap_cbus_config * cbus_config; struct cbus_host *chost; int ret; chost = kmalloc(sizeof (*chost), GFP_KERNEL); if (chost == NULL) return -ENOMEM; memset(chost, 0, sizeof (*chost)); spin_lock_init(&chost->lock); cbus_config = omap_get_config(OMAP_TAG_CBUS, struct omap_cbus_config); if (cbus_config == NULL) { printk(KERN_ERR "cbus: Unable to retrieve config data\n"); return -ENODATA; } chost->clk_gpio = cbus_config->clk_gpio; chost->dat_gpio = cbus_config->dat_gpio; chost->sel_gpio = cbus_config->sel_gpio; #ifdef CONFIG_ARCH_OMAP1 if (!OMAP_GPIO_IS_MPUIO(chost->clk_gpio) || !OMAP_GPIO_IS_MPUIO(chost->dat_gpio) || !OMAP_GPIO_IS_MPUIO(chost->sel_gpio)) { printk(KERN_ERR "cbus: Only MPUIO pins supported\n"); ret = -ENODEV; goto exit1; } #endif if ((ret = gpio_request(chost->clk_gpio, "CBUS clk")) < 0) goto exit1; if ((ret = gpio_request(chost->dat_gpio, "CBUS data")) < 0) goto exit2; if ((ret = gpio_request(chost->sel_gpio, "CBUS sel")) < 0) goto exit3; gpio_direction_output(chost->clk_gpio, 0); gpio_direction_input(chost->dat_gpio); gpio_direction_output(chost->sel_gpio, 1); gpio_set_value(chost->clk_gpio, 1); gpio_set_value(chost->clk_gpio, 0); cbus_host = chost; return 0; exit3: gpio_free(chost->dat_gpio); exit2: gpio_free(chost->clk_gpio); exit1: kfree(chost); return ret; }