mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-18 13:36:46 +07: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>
304 lines
8.5 KiB
C
304 lines
8.5 KiB
C
/*
|
|
* arch/arm/mach-ep93xx/vision_ep9307.c
|
|
* Vision Engraving Systems EP9307 SoM support.
|
|
*
|
|
* Copyright (C) 2008-2011 Vision Engraving Systems
|
|
* H Hartley Sweeten <hsweeten@visionengravers.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.
|
|
*/
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/init.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/irq.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/fb.h>
|
|
#include <linux/io.h>
|
|
#include <linux/mtd/partitions.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/platform_data/pca953x.h>
|
|
#include <linux/spi/spi.h>
|
|
#include <linux/spi/flash.h>
|
|
#include <linux/spi/mmc_spi.h>
|
|
#include <linux/mmc/host.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/map.h>
|
|
#include <asm/mach/arch.h>
|
|
|
|
#include "soc.h"
|
|
|
|
/*************************************************************************
|
|
* Static I/O mappings for the FPGA
|
|
*************************************************************************/
|
|
#define VISION_PHYS_BASE EP93XX_CS7_PHYS_BASE
|
|
#define VISION_VIRT_BASE 0xfebff000
|
|
|
|
static struct map_desc vision_io_desc[] __initdata = {
|
|
{
|
|
.virtual = VISION_VIRT_BASE,
|
|
.pfn = __phys_to_pfn(VISION_PHYS_BASE),
|
|
.length = SZ_4K,
|
|
.type = MT_DEVICE,
|
|
},
|
|
};
|
|
|
|
static void __init vision_map_io(void)
|
|
{
|
|
ep93xx_map_io();
|
|
|
|
iotable_init(vision_io_desc, ARRAY_SIZE(vision_io_desc));
|
|
}
|
|
|
|
/*************************************************************************
|
|
* Ethernet
|
|
*************************************************************************/
|
|
static struct ep93xx_eth_data vision_eth_data __initdata = {
|
|
.phy_id = 1,
|
|
};
|
|
|
|
/*************************************************************************
|
|
* Framebuffer
|
|
*************************************************************************/
|
|
#define VISION_LCD_ENABLE EP93XX_GPIO_LINE_EGPIO1
|
|
|
|
static int vision_lcd_setup(struct platform_device *pdev)
|
|
{
|
|
int err;
|
|
|
|
err = gpio_request_one(VISION_LCD_ENABLE, GPIOF_INIT_HIGH,
|
|
dev_name(&pdev->dev));
|
|
if (err)
|
|
return err;
|
|
|
|
ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_RAS |
|
|
EP93XX_SYSCON_DEVCFG_RASONP3 |
|
|
EP93XX_SYSCON_DEVCFG_EXVC);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void vision_lcd_teardown(struct platform_device *pdev)
|
|
{
|
|
gpio_free(VISION_LCD_ENABLE);
|
|
}
|
|
|
|
static void vision_lcd_blank(int blank_mode, struct fb_info *info)
|
|
{
|
|
if (blank_mode)
|
|
gpio_set_value(VISION_LCD_ENABLE, 0);
|
|
else
|
|
gpio_set_value(VISION_LCD_ENABLE, 1);
|
|
}
|
|
|
|
static struct ep93xxfb_mach_info ep93xxfb_info __initdata = {
|
|
.flags = EP93XXFB_USE_SDCSN0 | EP93XXFB_PCLK_FALLING,
|
|
.setup = vision_lcd_setup,
|
|
.teardown = vision_lcd_teardown,
|
|
.blank = vision_lcd_blank,
|
|
};
|
|
|
|
|
|
/*************************************************************************
|
|
* GPIO Expanders
|
|
*************************************************************************/
|
|
#define PCA9539_74_GPIO_BASE (EP93XX_GPIO_LINE_MAX + 1)
|
|
#define PCA9539_75_GPIO_BASE (PCA9539_74_GPIO_BASE + 16)
|
|
#define PCA9539_76_GPIO_BASE (PCA9539_75_GPIO_BASE + 16)
|
|
#define PCA9539_77_GPIO_BASE (PCA9539_76_GPIO_BASE + 16)
|
|
|
|
static struct pca953x_platform_data pca953x_74_gpio_data = {
|
|
.gpio_base = PCA9539_74_GPIO_BASE,
|
|
.irq_base = EP93XX_BOARD_IRQ(0),
|
|
};
|
|
|
|
static struct pca953x_platform_data pca953x_75_gpio_data = {
|
|
.gpio_base = PCA9539_75_GPIO_BASE,
|
|
.irq_base = -1,
|
|
};
|
|
|
|
static struct pca953x_platform_data pca953x_76_gpio_data = {
|
|
.gpio_base = PCA9539_76_GPIO_BASE,
|
|
.irq_base = -1,
|
|
};
|
|
|
|
static struct pca953x_platform_data pca953x_77_gpio_data = {
|
|
.gpio_base = PCA9539_77_GPIO_BASE,
|
|
.irq_base = -1,
|
|
};
|
|
|
|
/*************************************************************************
|
|
* I2C Bus
|
|
*************************************************************************/
|
|
|
|
static struct i2c_board_info vision_i2c_info[] __initdata = {
|
|
{
|
|
I2C_BOARD_INFO("isl1208", 0x6f),
|
|
.irq = IRQ_EP93XX_EXT1,
|
|
}, {
|
|
I2C_BOARD_INFO("pca9539", 0x74),
|
|
.platform_data = &pca953x_74_gpio_data,
|
|
}, {
|
|
I2C_BOARD_INFO("pca9539", 0x75),
|
|
.platform_data = &pca953x_75_gpio_data,
|
|
}, {
|
|
I2C_BOARD_INFO("pca9539", 0x76),
|
|
.platform_data = &pca953x_76_gpio_data,
|
|
}, {
|
|
I2C_BOARD_INFO("pca9539", 0x77),
|
|
.platform_data = &pca953x_77_gpio_data,
|
|
},
|
|
};
|
|
|
|
/*************************************************************************
|
|
* SPI CS4271 Audio Codec
|
|
*************************************************************************/
|
|
static struct cs4271_platform_data vision_cs4271_data = {
|
|
.gpio_nreset = EP93XX_GPIO_LINE_H(2),
|
|
};
|
|
|
|
/*************************************************************************
|
|
* SPI Flash
|
|
*************************************************************************/
|
|
static struct mtd_partition vision_spi_flash_partitions[] = {
|
|
{
|
|
.name = "SPI bootstrap",
|
|
.offset = 0,
|
|
.size = SZ_4K,
|
|
}, {
|
|
.name = "Bootstrap config",
|
|
.offset = MTDPART_OFS_APPEND,
|
|
.size = SZ_4K,
|
|
}, {
|
|
.name = "System config",
|
|
.offset = MTDPART_OFS_APPEND,
|
|
.size = MTDPART_SIZ_FULL,
|
|
},
|
|
};
|
|
|
|
static struct flash_platform_data vision_spi_flash_data = {
|
|
.name = "SPI Flash",
|
|
.parts = vision_spi_flash_partitions,
|
|
.nr_parts = ARRAY_SIZE(vision_spi_flash_partitions),
|
|
};
|
|
|
|
/*************************************************************************
|
|
* SPI SD/MMC host
|
|
*************************************************************************/
|
|
static struct mmc_spi_platform_data vision_spi_mmc_data = {
|
|
.detect_delay = 100,
|
|
.powerup_msecs = 100,
|
|
.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
|
|
.flags = MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO,
|
|
.cd_gpio = EP93XX_GPIO_LINE_EGPIO15,
|
|
.cd_debounce = 1,
|
|
.ro_gpio = EP93XX_GPIO_LINE_F(0),
|
|
.caps2 = MMC_CAP2_RO_ACTIVE_HIGH,
|
|
};
|
|
|
|
/*************************************************************************
|
|
* SPI Bus
|
|
*************************************************************************/
|
|
static struct spi_board_info vision_spi_board_info[] __initdata = {
|
|
{
|
|
.modalias = "cs4271",
|
|
.platform_data = &vision_cs4271_data,
|
|
.max_speed_hz = 6000000,
|
|
.bus_num = 0,
|
|
.chip_select = 0,
|
|
.mode = SPI_MODE_3,
|
|
}, {
|
|
.modalias = "sst25l",
|
|
.platform_data = &vision_spi_flash_data,
|
|
.max_speed_hz = 20000000,
|
|
.bus_num = 0,
|
|
.chip_select = 1,
|
|
.mode = SPI_MODE_3,
|
|
}, {
|
|
.modalias = "mmc_spi",
|
|
.platform_data = &vision_spi_mmc_data,
|
|
.max_speed_hz = 20000000,
|
|
.bus_num = 0,
|
|
.chip_select = 2,
|
|
.mode = SPI_MODE_3,
|
|
},
|
|
};
|
|
|
|
static int vision_spi_chipselects[] __initdata = {
|
|
EP93XX_GPIO_LINE_EGPIO6,
|
|
EP93XX_GPIO_LINE_EGPIO7,
|
|
EP93XX_GPIO_LINE_G(2),
|
|
};
|
|
|
|
static struct ep93xx_spi_info vision_spi_master __initdata = {
|
|
.chipselect = vision_spi_chipselects,
|
|
.num_chipselect = ARRAY_SIZE(vision_spi_chipselects),
|
|
.use_dma = 1,
|
|
};
|
|
|
|
/*************************************************************************
|
|
* I2S Audio
|
|
*************************************************************************/
|
|
static struct platform_device vision_audio_device = {
|
|
.name = "edb93xx-audio",
|
|
.id = -1,
|
|
};
|
|
|
|
static void __init vision_register_i2s(void)
|
|
{
|
|
ep93xx_register_i2s();
|
|
platform_device_register(&vision_audio_device);
|
|
}
|
|
|
|
/*************************************************************************
|
|
* Machine Initialization
|
|
*************************************************************************/
|
|
static void __init vision_init_machine(void)
|
|
{
|
|
ep93xx_init_devices();
|
|
ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_64M);
|
|
ep93xx_register_eth(&vision_eth_data, 1);
|
|
ep93xx_register_fb(&ep93xxfb_info);
|
|
ep93xx_register_pwm(1, 0);
|
|
|
|
/*
|
|
* Request the gpio expander's interrupt gpio line now to prevent
|
|
* the kernel from doing a WARN in gpiolib:gpio_ensure_requested().
|
|
*/
|
|
if (gpio_request_one(EP93XX_GPIO_LINE_F(7), GPIOF_DIR_IN,
|
|
"pca9539:74"))
|
|
pr_warn("cannot request interrupt gpio for pca9539:74\n");
|
|
|
|
vision_i2c_info[1].irq = gpio_to_irq(EP93XX_GPIO_LINE_F(7));
|
|
|
|
ep93xx_register_i2c(vision_i2c_info,
|
|
ARRAY_SIZE(vision_i2c_info));
|
|
ep93xx_register_spi(&vision_spi_master, vision_spi_board_info,
|
|
ARRAY_SIZE(vision_spi_board_info));
|
|
vision_register_i2s();
|
|
}
|
|
|
|
MACHINE_START(VISION_EP9307, "Vision Engraving Systems EP9307")
|
|
/* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
|
|
.atag_offset = 0x100,
|
|
.map_io = vision_map_io,
|
|
.init_irq = ep93xx_init_irq,
|
|
.init_time = ep93xx_timer_init,
|
|
.init_machine = vision_init_machine,
|
|
.init_late = ep93xx_init_late,
|
|
.restart = ep93xx_restart,
|
|
MACHINE_END
|