mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-28 07:04:00 +08:00
b2e6355559
This converts the GPIO-based I2C-driver to using GPIO descriptors instead of the old global numberspace-based GPIO interface. We: - Convert the driver to unconditionally grab two GPIOs from the device by index 0 (SDA) and 1 (SCL) which will work fine with device tree and descriptor tables. The existing device trees will continue to work just like before, but without any roundtrip through the global numberspace. - Brutally convert all boardfiles still passing global GPIOs by registering descriptor tables associated with the devices instead so this driver does not need to keep supporting passing any GPIO numbers as platform data. There is no stepwise approach as elegant as this, I strongly prefer this big hammer over any antsteps for this conversion. This way the old GPIO numbers go away and NEVER COME BACK. Special conversion for the different boards utilizing I2C-GPIO: - EP93xx (arch/arm/mach-ep93xx): pretty straight forward as all boards were using the same two GPIO lines, just define these two in a lookup table for "i2c-gpio" and register these along with the device. None of them define any other platform data so just pass NULL as platform data. This platform selects GPIOLIB so all should be smooth. The pins appear on a gpiochip for bank "G" as pins 1 (SDA) and 0 (SCL). - IXP4 (arch/arm/mach-ixp4): descriptor tables have to be registered for each board separately. They all use "IXP4XX_GPIO_CHIP" so it is pretty straight forward. Most board define no other platform data than SCL/SDA so they can drop the #include of <linux/i2c-gpio.h> and assign NULL to platform data. The "goramo_mlr" (Goramo Multilink Router) board is a bit worrisome: it implements its own I2C bit-banging in the board file, and optionally registers an I2C serial port, but claims the same GPIO lines for itself in the board file. This is not going to work: there will be competition for the GPIO lines, so delete the optional extra I2C bus instead, no I2C devices are registered on it anyway, there are just hints that it may contain an EEPROM that may be accessed from userspace. This needs to be fixed up properly by the serial clock using I2C emulation so drop a note in the code. - KS8695 board acs5k (arch/arm/mach-ks8695/board-acs5.c) has some platform data in addition to the pins so it needs to be kept around sans GPIO lines. Its GPIO chip is named "KS8695" and the arch selects GPIOLIB. - PXA boards (arch/arm/mach-pxa/*) use some of the platform data so it needs to be preserved here. The viper board even registers two GPIO I2Cs. The gpiochip is named "gpio-pxa" and the arch selects GPIOLIB. - SA1100 Simpad (arch/arm/mach-sa1100/simpad.c) defines a GPIO I2C bus, and the arch selects GPIOLIB. - Blackfin boards (arch/blackfin/bf533 etc) for these I assume their I2C GPIOs refer to the local gpiochip defined in arch/blackfin/kernel/bfin_gpio.c names "BFIN-GPIO". The arch selects GPIOLIB. The boards get spiked with IF_ENABLED(I2C_GPIO) but that is a side effect of it being like that already (I would just have Kconfig select I2C_GPIO and get rid of them all.) I also delete any platform data set to 0 as it will get that value anyway from static declartions of platform data. - The MIPS selects GPIOLIB and the Alchemy machine is using two local GPIO chips, one of them has a GPIO I2C. We need to adjust the local offset from the global number space here. The ATH79 has a proper GPIO driver in drivers/gpio/gpio-ath79.c and AFAICT the chip is named "ath79-gpio" and the PB44 PCF857x expander spawns from this on GPIO 1 and 0. The latter board only use the platform data to specify pins so it can be cut altogether after this. - The MFD Silicon Motion SM501 is a special case. It dynamically spawns an I2C bus off the MFD using sm501_create_subdev(). We use an approach to dynamically create a machine descriptor table and attach this to the "SM501-LOW" or "SM501-HIGH" gpiochip. We use chip-local offsets to grab the right lines. We can get rid of two local static inline helpers as part of this refactoring. Cc: Steven Miao <realmz6@gmail.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Guenter Roeck <linux@roeck-us.net> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Magnus Damm <magnus.damm@gmail.com> Cc: Ben Dooks <ben.dooks@codethink.co.uk> Cc: Heiko Schocher <hs@denx.de> Acked-by: Wu, Aaron <Aaron.Wu@analog.com> Acked-by: Olof Johansson <olof@lixom.net> Acked-by: Lee Jones <lee.jones@linaro.org> Acked-by: Ralf Baechle <ralf@linux-mips.org> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
344 lines
9.4 KiB
C
344 lines
9.4 KiB
C
/*
|
|
* arch/arm/mach-ep93xx/edb93xx.c
|
|
* Cirrus Logic EDB93xx Development Board support.
|
|
*
|
|
* EDB93XX, EDB9301, EDB9307A
|
|
* Copyright (C) 2008-2009 H Hartley Sweeten <hsweeten@visionengravers.com>
|
|
*
|
|
* EDB9302
|
|
* Copyright (C) 2006 George Kashperko <george@chas.com.ua>
|
|
*
|
|
* EDB9302A, EDB9315, EDB9315A
|
|
* Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
|
|
*
|
|
* EDB9307
|
|
* Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
|
|
*
|
|
* EDB9312
|
|
* Copyright (C) 2006 Infosys Technologies Limited
|
|
* Toufeeq Hussain <toufeeq_hussain@infosys.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
* your option) any later version.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/init.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/spi/spi.h>
|
|
|
|
#include <sound/cs4271.h>
|
|
|
|
#include <mach/hardware.h>
|
|
#include <linux/platform_data/video-ep93xx.h>
|
|
#include <linux/platform_data/spi-ep93xx.h>
|
|
#include <mach/gpio-ep93xx.h>
|
|
|
|
#include <asm/mach-types.h>
|
|
#include <asm/mach/arch.h>
|
|
|
|
#include "soc.h"
|
|
|
|
static void __init edb93xx_register_flash(void)
|
|
{
|
|
if (machine_is_edb9307() || machine_is_edb9312() ||
|
|
machine_is_edb9315()) {
|
|
ep93xx_register_flash(4, EP93XX_CS6_PHYS_BASE, SZ_32M);
|
|
} else {
|
|
ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_16M);
|
|
}
|
|
}
|
|
|
|
static struct ep93xx_eth_data __initdata edb93xx_eth_data = {
|
|
.phy_id = 1,
|
|
};
|
|
|
|
|
|
/*************************************************************************
|
|
* EDB93xx i2c peripheral handling
|
|
*************************************************************************/
|
|
|
|
static struct i2c_board_info __initdata edb93xxa_i2c_board_info[] = {
|
|
{
|
|
I2C_BOARD_INFO("isl1208", 0x6f),
|
|
},
|
|
};
|
|
|
|
static struct i2c_board_info __initdata edb93xx_i2c_board_info[] = {
|
|
{
|
|
I2C_BOARD_INFO("ds1337", 0x68),
|
|
},
|
|
};
|
|
|
|
static void __init edb93xx_register_i2c(void)
|
|
{
|
|
if (machine_is_edb9302a() || machine_is_edb9307a() ||
|
|
machine_is_edb9315a()) {
|
|
ep93xx_register_i2c(edb93xxa_i2c_board_info,
|
|
ARRAY_SIZE(edb93xxa_i2c_board_info));
|
|
} else if (machine_is_edb9302() || machine_is_edb9307()
|
|
|| machine_is_edb9312() || machine_is_edb9315()) {
|
|
ep93xx_register_i2c(edb93xx_i2c_board_info,
|
|
ARRAY_SIZE(edb93xx_i2c_board_info));
|
|
}
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* EDB93xx SPI peripheral handling
|
|
*************************************************************************/
|
|
static struct cs4271_platform_data edb93xx_cs4271_data = {
|
|
.gpio_nreset = -EINVAL, /* filled in later */
|
|
};
|
|
|
|
static struct spi_board_info edb93xx_spi_board_info[] __initdata = {
|
|
{
|
|
.modalias = "cs4271",
|
|
.platform_data = &edb93xx_cs4271_data,
|
|
.max_speed_hz = 6000000,
|
|
.bus_num = 0,
|
|
.chip_select = 0,
|
|
.mode = SPI_MODE_3,
|
|
},
|
|
};
|
|
|
|
static int edb93xx_spi_chipselects[] __initdata = {
|
|
EP93XX_GPIO_LINE_EGPIO6,
|
|
};
|
|
|
|
static struct ep93xx_spi_info edb93xx_spi_info __initdata = {
|
|
.chipselect = edb93xx_spi_chipselects,
|
|
.num_chipselect = ARRAY_SIZE(edb93xx_spi_chipselects),
|
|
};
|
|
|
|
static void __init edb93xx_register_spi(void)
|
|
{
|
|
if (machine_is_edb9301() || machine_is_edb9302())
|
|
edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO1;
|
|
else if (machine_is_edb9302a() || machine_is_edb9307a())
|
|
edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_H(2);
|
|
else if (machine_is_edb9315a())
|
|
edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO14;
|
|
|
|
ep93xx_register_spi(&edb93xx_spi_info, edb93xx_spi_board_info,
|
|
ARRAY_SIZE(edb93xx_spi_board_info));
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* EDB93xx I2S
|
|
*************************************************************************/
|
|
static struct platform_device edb93xx_audio_device = {
|
|
.name = "edb93xx-audio",
|
|
.id = -1,
|
|
};
|
|
|
|
static int __init edb93xx_has_audio(void)
|
|
{
|
|
return (machine_is_edb9301() || machine_is_edb9302() ||
|
|
machine_is_edb9302a() || machine_is_edb9307a() ||
|
|
machine_is_edb9315a());
|
|
}
|
|
|
|
static void __init edb93xx_register_i2s(void)
|
|
{
|
|
if (edb93xx_has_audio()) {
|
|
ep93xx_register_i2s();
|
|
platform_device_register(&edb93xx_audio_device);
|
|
}
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* EDB93xx pwm
|
|
*************************************************************************/
|
|
static void __init edb93xx_register_pwm(void)
|
|
{
|
|
if (machine_is_edb9301() ||
|
|
machine_is_edb9302() || machine_is_edb9302a()) {
|
|
/* EP9301 and EP9302 only have pwm.1 (EGPIO14) */
|
|
ep93xx_register_pwm(0, 1);
|
|
} else if (machine_is_edb9307() || machine_is_edb9307a()) {
|
|
/* EP9307 only has pwm.0 (PWMOUT) */
|
|
ep93xx_register_pwm(1, 0);
|
|
} else {
|
|
/* EP9312 and EP9315 have both */
|
|
ep93xx_register_pwm(1, 1);
|
|
}
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* EDB93xx framebuffer
|
|
*************************************************************************/
|
|
static struct ep93xxfb_mach_info __initdata edb93xxfb_info = {
|
|
.flags = 0,
|
|
};
|
|
|
|
static int __init edb93xx_has_fb(void)
|
|
{
|
|
/* These platforms have an ep93xx with video capability */
|
|
return machine_is_edb9307() || machine_is_edb9307a() ||
|
|
machine_is_edb9312() || machine_is_edb9315() ||
|
|
machine_is_edb9315a();
|
|
}
|
|
|
|
static void __init edb93xx_register_fb(void)
|
|
{
|
|
if (!edb93xx_has_fb())
|
|
return;
|
|
|
|
if (machine_is_edb9307a() || machine_is_edb9315a())
|
|
edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN0;
|
|
else
|
|
edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN3;
|
|
|
|
ep93xx_register_fb(&edb93xxfb_info);
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* EDB93xx IDE
|
|
*************************************************************************/
|
|
static int __init edb93xx_has_ide(void)
|
|
{
|
|
/*
|
|
* Although EDB9312 and EDB9315 do have IDE capability, they have
|
|
* INTRQ line wired as pull-up, which makes using IDE interface
|
|
* problematic.
|
|
*/
|
|
return machine_is_edb9312() || machine_is_edb9315() ||
|
|
machine_is_edb9315a();
|
|
}
|
|
|
|
static void __init edb93xx_register_ide(void)
|
|
{
|
|
if (!edb93xx_has_ide())
|
|
return;
|
|
|
|
ep93xx_register_ide();
|
|
}
|
|
|
|
|
|
static void __init edb93xx_init_machine(void)
|
|
{
|
|
ep93xx_init_devices();
|
|
edb93xx_register_flash();
|
|
ep93xx_register_eth(&edb93xx_eth_data, 1);
|
|
edb93xx_register_i2c();
|
|
edb93xx_register_spi();
|
|
edb93xx_register_i2s();
|
|
edb93xx_register_pwm();
|
|
edb93xx_register_fb();
|
|
edb93xx_register_ide();
|
|
ep93xx_register_adc();
|
|
}
|
|
|
|
|
|
#ifdef CONFIG_MACH_EDB9301
|
|
MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board")
|
|
/* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
|
|
.atag_offset = 0x100,
|
|
.map_io = ep93xx_map_io,
|
|
.init_irq = ep93xx_init_irq,
|
|
.init_time = ep93xx_timer_init,
|
|
.init_machine = edb93xx_init_machine,
|
|
.init_late = ep93xx_init_late,
|
|
.restart = ep93xx_restart,
|
|
MACHINE_END
|
|
#endif
|
|
|
|
#ifdef CONFIG_MACH_EDB9302
|
|
MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board")
|
|
/* Maintainer: George Kashperko <george@chas.com.ua> */
|
|
.atag_offset = 0x100,
|
|
.map_io = ep93xx_map_io,
|
|
.init_irq = ep93xx_init_irq,
|
|
.init_time = ep93xx_timer_init,
|
|
.init_machine = edb93xx_init_machine,
|
|
.init_late = ep93xx_init_late,
|
|
.restart = ep93xx_restart,
|
|
MACHINE_END
|
|
#endif
|
|
|
|
#ifdef CONFIG_MACH_EDB9302A
|
|
MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
|
|
/* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
|
|
.atag_offset = 0x100,
|
|
.map_io = ep93xx_map_io,
|
|
.init_irq = ep93xx_init_irq,
|
|
.init_time = ep93xx_timer_init,
|
|
.init_machine = edb93xx_init_machine,
|
|
.init_late = ep93xx_init_late,
|
|
.restart = ep93xx_restart,
|
|
MACHINE_END
|
|
#endif
|
|
|
|
#ifdef CONFIG_MACH_EDB9307
|
|
MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
|
|
/* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
|
|
.atag_offset = 0x100,
|
|
.map_io = ep93xx_map_io,
|
|
.init_irq = ep93xx_init_irq,
|
|
.init_time = ep93xx_timer_init,
|
|
.init_machine = edb93xx_init_machine,
|
|
.init_late = ep93xx_init_late,
|
|
.restart = ep93xx_restart,
|
|
MACHINE_END
|
|
#endif
|
|
|
|
#ifdef CONFIG_MACH_EDB9307A
|
|
MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board")
|
|
/* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
|
|
.atag_offset = 0x100,
|
|
.map_io = ep93xx_map_io,
|
|
.init_irq = ep93xx_init_irq,
|
|
.init_time = ep93xx_timer_init,
|
|
.init_machine = edb93xx_init_machine,
|
|
.init_late = ep93xx_init_late,
|
|
.restart = ep93xx_restart,
|
|
MACHINE_END
|
|
#endif
|
|
|
|
#ifdef CONFIG_MACH_EDB9312
|
|
MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
|
|
/* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */
|
|
.atag_offset = 0x100,
|
|
.map_io = ep93xx_map_io,
|
|
.init_irq = ep93xx_init_irq,
|
|
.init_time = ep93xx_timer_init,
|
|
.init_machine = edb93xx_init_machine,
|
|
.init_late = ep93xx_init_late,
|
|
.restart = ep93xx_restart,
|
|
MACHINE_END
|
|
#endif
|
|
|
|
#ifdef CONFIG_MACH_EDB9315
|
|
MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
|
|
/* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
|
|
.atag_offset = 0x100,
|
|
.map_io = ep93xx_map_io,
|
|
.init_irq = ep93xx_init_irq,
|
|
.init_time = ep93xx_timer_init,
|
|
.init_machine = edb93xx_init_machine,
|
|
.init_late = ep93xx_init_late,
|
|
.restart = ep93xx_restart,
|
|
MACHINE_END
|
|
#endif
|
|
|
|
#ifdef CONFIG_MACH_EDB9315A
|
|
MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
|
|
/* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
|
|
.atag_offset = 0x100,
|
|
.map_io = ep93xx_map_io,
|
|
.init_irq = ep93xx_init_irq,
|
|
.init_time = ep93xx_timer_init,
|
|
.init_machine = edb93xx_init_machine,
|
|
.init_late = ep93xx_init_late,
|
|
.restart = ep93xx_restart,
|
|
MACHINE_END
|
|
#endif
|