2008-08-29 22:47:52 +08:00
|
|
|
/*
|
|
|
|
* Hardware definitions for Palm Zire72
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Vladimir "Farcaller" Pouzanov <farcaller@gmail.com>
|
|
|
|
* Sergey Lapin <slapin@ossfans.org>
|
|
|
|
* Alex Osborne <bobofdoom@gmail.com>
|
|
|
|
* Jan Herman <2hp@seznam.cz>
|
|
|
|
*
|
|
|
|
* Rewrite for mainline:
|
|
|
|
* Marek Vasut <marek.vasut@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* (find more info at www.hackndev.com)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/platform_device.h>
|
2011-04-23 04:03:11 +08:00
|
|
|
#include <linux/syscore_ops.h>
|
2008-08-29 22:47:52 +08:00
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/gpio_keys.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <linux/pda_power.h>
|
|
|
|
#include <linux/pwm_backlight.h>
|
|
|
|
#include <linux/gpio.h>
|
2010-06-04 09:07:33 +08:00
|
|
|
#include <linux/wm97xx.h>
|
2008-08-29 22:47:52 +08:00
|
|
|
#include <linux/power_supply.h>
|
2009-06-02 04:34:14 +08:00
|
|
|
#include <linux/usb/gpio_vbus.h>
|
2011-01-13 18:45:30 +08:00
|
|
|
#include <linux/i2c-gpio.h>
|
i2c: gpio: Convert to use descriptors
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>
2017-09-10 07:30:46 +08:00
|
|
|
#include <linux/gpio/machine.h>
|
2008-08-29 22:47:52 +08:00
|
|
|
|
|
|
|
#include <asm/mach-types.h>
|
2011-06-23 00:41:48 +08:00
|
|
|
#include <asm/suspend.h>
|
2008-08-29 22:47:52 +08:00
|
|
|
#include <asm/mach/arch.h>
|
|
|
|
#include <asm/mach/map.h>
|
|
|
|
|
2015-01-30 17:45:33 +08:00
|
|
|
#include "pxa27x.h"
|
2008-08-29 22:47:52 +08:00
|
|
|
#include <mach/audio.h>
|
2015-01-30 17:45:33 +08:00
|
|
|
#include "palmz72.h"
|
2012-08-24 21:16:48 +08:00
|
|
|
#include <linux/platform_data/mmc-pxamci.h>
|
|
|
|
#include <linux/platform_data/video-pxafb.h>
|
|
|
|
#include <linux/platform_data/irda-pxaficp.h>
|
|
|
|
#include <linux/platform_data/keypad-pxa27x.h>
|
2015-01-30 17:45:33 +08:00
|
|
|
#include "udc.h"
|
2012-08-24 21:16:48 +08:00
|
|
|
#include <linux/platform_data/asoc-palm27x.h>
|
2015-01-30 17:45:33 +08:00
|
|
|
#include "palm27x.h"
|
2009-06-02 04:34:14 +08:00
|
|
|
|
2015-01-30 17:45:33 +08:00
|
|
|
#include "pm.h"
|
2015-11-17 17:11:13 +08:00
|
|
|
#include <linux/platform_data/media/camera-pxa.h>
|
2011-01-13 18:45:30 +08:00
|
|
|
|
|
|
|
#include <media/soc_camera.h>
|
2008-08-29 22:47:52 +08:00
|
|
|
|
|
|
|
#include "generic.h"
|
|
|
|
#include "devices.h"
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Pin configuration
|
|
|
|
******************************************************************************/
|
|
|
|
static unsigned long palmz72_pin_config[] __initdata = {
|
|
|
|
/* MMC */
|
|
|
|
GPIO32_MMC_CLK,
|
|
|
|
GPIO92_MMC_DAT_0,
|
|
|
|
GPIO109_MMC_DAT_1,
|
|
|
|
GPIO110_MMC_DAT_2,
|
|
|
|
GPIO111_MMC_DAT_3,
|
|
|
|
GPIO112_MMC_CMD,
|
|
|
|
GPIO14_GPIO, /* SD detect */
|
|
|
|
GPIO115_GPIO, /* SD RO */
|
|
|
|
GPIO98_GPIO, /* SD power */
|
|
|
|
|
|
|
|
/* AC97 */
|
|
|
|
GPIO28_AC97_BITCLK,
|
|
|
|
GPIO29_AC97_SDATA_IN_0,
|
|
|
|
GPIO30_AC97_SDATA_OUT,
|
|
|
|
GPIO31_AC97_SYNC,
|
2009-06-02 04:34:14 +08:00
|
|
|
GPIO89_AC97_SYSCLK,
|
|
|
|
GPIO113_AC97_nRESET,
|
2008-08-29 22:47:52 +08:00
|
|
|
|
|
|
|
/* IrDA */
|
|
|
|
GPIO49_GPIO, /* ir disable */
|
|
|
|
GPIO46_FICP_RXD,
|
|
|
|
GPIO47_FICP_TXD,
|
|
|
|
|
|
|
|
/* PWM */
|
|
|
|
GPIO16_PWM0_OUT,
|
|
|
|
|
|
|
|
/* USB */
|
|
|
|
GPIO15_GPIO, /* usb detect */
|
2009-06-02 04:34:14 +08:00
|
|
|
GPIO95_GPIO, /* usb pullup */
|
2008-08-29 22:47:52 +08:00
|
|
|
|
|
|
|
/* Matrix keypad */
|
|
|
|
GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
|
|
|
|
GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
|
|
|
|
GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
|
|
|
|
GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
|
|
|
|
GPIO103_KP_MKOUT_0,
|
|
|
|
GPIO104_KP_MKOUT_1,
|
|
|
|
GPIO105_KP_MKOUT_2,
|
|
|
|
|
|
|
|
/* LCD */
|
2010-01-04 11:37:14 +08:00
|
|
|
GPIOxx_LCD_TFT_16BPP,
|
|
|
|
|
2008-08-29 22:47:52 +08:00
|
|
|
GPIO20_GPIO, /* bl power */
|
|
|
|
GPIO21_GPIO, /* LCD border switch */
|
|
|
|
GPIO22_GPIO, /* LCD border color */
|
|
|
|
GPIO96_GPIO, /* lcd power */
|
|
|
|
|
2011-01-13 18:45:30 +08:00
|
|
|
/* PXA Camera */
|
|
|
|
GPIO81_CIF_DD_0,
|
|
|
|
GPIO48_CIF_DD_5,
|
|
|
|
GPIO50_CIF_DD_3,
|
|
|
|
GPIO51_CIF_DD_2,
|
|
|
|
GPIO52_CIF_DD_4,
|
|
|
|
GPIO53_CIF_MCLK,
|
|
|
|
GPIO54_CIF_PCLK,
|
|
|
|
GPIO55_CIF_DD_1,
|
|
|
|
GPIO84_CIF_FV,
|
|
|
|
GPIO85_CIF_LV,
|
|
|
|
GPIO93_CIF_DD_6,
|
|
|
|
GPIO108_CIF_DD_7,
|
|
|
|
|
|
|
|
GPIO56_GPIO, /* OV9640 Powerdown */
|
|
|
|
GPIO57_GPIO, /* OV9640 Reset */
|
|
|
|
GPIO91_GPIO, /* OV9640 Power */
|
|
|
|
|
|
|
|
/* I2C */
|
|
|
|
GPIO117_GPIO, /* I2C_SCL */
|
|
|
|
GPIO118_GPIO, /* I2C_SDA */
|
|
|
|
|
2008-08-29 22:47:52 +08:00
|
|
|
/* Misc. */
|
|
|
|
GPIO0_GPIO | WAKEUP_ON_LEVEL_HIGH, /* power detect */
|
|
|
|
GPIO88_GPIO, /* green led */
|
|
|
|
GPIO27_GPIO, /* WM9712 IRQ */
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GPIO keyboard
|
|
|
|
******************************************************************************/
|
2010-07-13 14:16:45 +08:00
|
|
|
#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
|
2013-05-06 11:24:58 +08:00
|
|
|
static const unsigned int palmz72_matrix_keys[] = {
|
2008-08-29 22:47:52 +08:00
|
|
|
KEY(0, 0, KEY_POWER),
|
|
|
|
KEY(0, 1, KEY_F1),
|
|
|
|
KEY(0, 2, KEY_ENTER),
|
|
|
|
|
|
|
|
KEY(1, 0, KEY_F2),
|
|
|
|
KEY(1, 1, KEY_F3),
|
|
|
|
KEY(1, 2, KEY_F4),
|
|
|
|
|
|
|
|
KEY(2, 0, KEY_UP),
|
|
|
|
KEY(2, 2, KEY_DOWN),
|
|
|
|
|
|
|
|
KEY(3, 0, KEY_RIGHT),
|
|
|
|
KEY(3, 2, KEY_LEFT),
|
|
|
|
};
|
|
|
|
|
2013-05-06 11:24:58 +08:00
|
|
|
static struct matrix_keymap_data almz72_matrix_keymap_data = {
|
|
|
|
.keymap = palmz72_matrix_keys,
|
|
|
|
.keymap_size = ARRAY_SIZE(palmz72_matrix_keys),
|
|
|
|
};
|
|
|
|
|
2008-08-29 22:47:52 +08:00
|
|
|
static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data = {
|
|
|
|
.matrix_key_rows = 4,
|
|
|
|
.matrix_key_cols = 3,
|
2013-05-06 11:24:58 +08:00
|
|
|
.matrix_keymap_data = &almz72_matrix_keymap_data,
|
2008-08-29 22:47:52 +08:00
|
|
|
|
|
|
|
.debounce_interval = 30,
|
|
|
|
};
|
|
|
|
|
2010-07-13 14:16:45 +08:00
|
|
|
static void __init palmz72_kpc_init(void)
|
2008-08-29 22:47:52 +08:00
|
|
|
{
|
2010-07-13 14:16:45 +08:00
|
|
|
pxa_set_keypad_info(&palmz72_keypad_platform_data);
|
2008-08-29 22:47:52 +08:00
|
|
|
}
|
2010-07-13 14:16:45 +08:00
|
|
|
#else
|
|
|
|
static inline void palmz72_kpc_init(void) {}
|
|
|
|
#endif
|
2008-08-29 22:47:52 +08:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* LEDs
|
|
|
|
******************************************************************************/
|
2010-07-13 14:16:45 +08:00
|
|
|
#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
|
2008-08-29 22:47:52 +08:00
|
|
|
static struct gpio_led gpio_leds[] = {
|
|
|
|
{
|
|
|
|
.name = "palmz72:green:led",
|
|
|
|
.default_trigger = "none",
|
|
|
|
.gpio = GPIO_NR_PALMZ72_LED_GREEN,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct gpio_led_platform_data gpio_led_info = {
|
|
|
|
.leds = gpio_leds,
|
|
|
|
.num_leds = ARRAY_SIZE(gpio_leds),
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device palmz72_leds = {
|
|
|
|
.name = "leds-gpio",
|
|
|
|
.id = -1,
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &gpio_led_info,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-07-13 14:16:45 +08:00
|
|
|
static void __init palmz72_leds_init(void)
|
2008-08-29 22:47:52 +08:00
|
|
|
{
|
2010-07-13 14:16:45 +08:00
|
|
|
platform_device_register(&palmz72_leds);
|
2008-08-29 22:47:52 +08:00
|
|
|
}
|
2010-07-13 14:16:45 +08:00
|
|
|
#else
|
|
|
|
static inline void palmz72_leds_init(void) {}
|
|
|
|
#endif
|
2008-08-29 22:47:52 +08:00
|
|
|
|
2008-08-29 22:53:24 +08:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
|
|
|
/* We have some black magic here
|
|
|
|
* PalmOS ROM on recover expects special struct physical address
|
|
|
|
* to be transferred via PSPR. Using this struct PalmOS restores
|
|
|
|
* its state after sleep. As for Linux, we need to setup it the
|
|
|
|
* same way. More than that, PalmOS ROM changes some values in memory.
|
|
|
|
* For now only one location is found, which needs special treatment.
|
|
|
|
* Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people
|
|
|
|
* for reading backtraces for me :)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
|
|
|
|
|
|
|
|
static struct palmz72_resume_info palmz72_resume_info = {
|
|
|
|
.magic0 = 0xb4e6,
|
|
|
|
.magic1 = 1,
|
|
|
|
|
|
|
|
/* reset state, MMU off etc */
|
|
|
|
.arm_control = 0,
|
|
|
|
.aux_control = 0,
|
|
|
|
.ttb = 0,
|
|
|
|
.domain_access = 0,
|
|
|
|
.process_id = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned long store_ptr;
|
|
|
|
|
2011-04-23 04:03:11 +08:00
|
|
|
/* syscore_ops for Palm Zire 72 PM */
|
2008-08-29 22:53:24 +08:00
|
|
|
|
2011-04-23 04:03:11 +08:00
|
|
|
static int palmz72_pm_suspend(void)
|
2008-08-29 22:53:24 +08:00
|
|
|
{
|
|
|
|
/* setup the resume_info struct for the original bootloader */
|
2011-02-07 01:41:26 +08:00
|
|
|
palmz72_resume_info.resume_addr = (u32) cpu_resume;
|
2008-08-29 22:53:24 +08:00
|
|
|
|
|
|
|
/* Storing memory touched by ROM */
|
|
|
|
store_ptr = *PALMZ72_SAVE_DWORD;
|
|
|
|
|
|
|
|
/* Setting PSPR to a proper value */
|
2017-01-15 10:59:29 +08:00
|
|
|
PSPR = __pa_symbol(&palmz72_resume_info);
|
2008-08-29 22:53:24 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-23 04:03:11 +08:00
|
|
|
static void palmz72_pm_resume(void)
|
2008-08-29 22:53:24 +08:00
|
|
|
{
|
|
|
|
*PALMZ72_SAVE_DWORD = store_ptr;
|
|
|
|
}
|
|
|
|
|
2011-04-23 04:03:11 +08:00
|
|
|
static struct syscore_ops palmz72_pm_syscore_ops = {
|
2008-08-29 22:53:24 +08:00
|
|
|
.suspend = palmz72_pm_suspend,
|
|
|
|
.resume = palmz72_pm_resume,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init palmz72_pm_init(void)
|
|
|
|
{
|
|
|
|
if (machine_is_palmz72()) {
|
2011-04-23 04:03:11 +08:00
|
|
|
register_syscore_ops(&palmz72_pm_syscore_ops);
|
|
|
|
return 0;
|
2008-08-29 22:53:24 +08:00
|
|
|
}
|
2011-04-23 04:03:11 +08:00
|
|
|
return -ENODEV;
|
2008-08-29 22:53:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
device_initcall(palmz72_pm_init);
|
|
|
|
#endif
|
|
|
|
|
2011-01-13 18:45:30 +08:00
|
|
|
/******************************************************************************
|
|
|
|
* SoC Camera
|
|
|
|
******************************************************************************/
|
|
|
|
#if defined(CONFIG_SOC_CAMERA_OV9640) || \
|
|
|
|
defined(CONFIG_SOC_CAMERA_OV9640_MODULE)
|
|
|
|
static struct pxacamera_platform_data palmz72_pxacamera_platform_data = {
|
|
|
|
.flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
|
|
|
|
PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
|
|
|
|
.mclk_10khz = 2600,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Board I2C devices. */
|
|
|
|
static struct i2c_board_info palmz72_i2c_device[] = {
|
|
|
|
{
|
|
|
|
I2C_BOARD_INFO("ov9640", 0x30),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static int palmz72_camera_power(struct device *dev, int power)
|
|
|
|
{
|
|
|
|
gpio_set_value(GPIO_NR_PALMZ72_CAM_PWDN, !power);
|
|
|
|
mdelay(50);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int palmz72_camera_reset(struct device *dev)
|
|
|
|
{
|
|
|
|
gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET, 1);
|
|
|
|
mdelay(50);
|
|
|
|
gpio_set_value(GPIO_NR_PALMZ72_CAM_RESET, 0);
|
|
|
|
mdelay(50);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct soc_camera_link palmz72_iclink = {
|
|
|
|
.bus_id = 0, /* Match id in pxa27x_device_camera in device.c */
|
|
|
|
.board_info = &palmz72_i2c_device[0],
|
|
|
|
.i2c_adapter_id = 0,
|
|
|
|
.module_name = "ov96xx",
|
|
|
|
.power = &palmz72_camera_power,
|
|
|
|
.reset = &palmz72_camera_reset,
|
|
|
|
.flags = SOCAM_DATAWIDTH_8,
|
|
|
|
};
|
|
|
|
|
i2c: gpio: Convert to use descriptors
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>
2017-09-10 07:30:46 +08:00
|
|
|
static struct gpiod_lookup_table palmz72_i2c_gpiod_table = {
|
|
|
|
.dev_id = "i2c-gpio",
|
|
|
|
.table = {
|
|
|
|
GPIO_LOOKUP_IDX("gpio-pxa", 118, NULL, 0, GPIO_ACTIVE_HIGH),
|
|
|
|
GPIO_LOOKUP_IDX("gpio-pxa", 117, NULL, 1, GPIO_ACTIVE_HIGH),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2011-01-13 18:45:30 +08:00
|
|
|
static struct i2c_gpio_platform_data palmz72_i2c_bus_data = {
|
|
|
|
.udelay = 10,
|
|
|
|
.timeout = 100,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device palmz72_i2c_bus_device = {
|
|
|
|
.name = "i2c-gpio",
|
|
|
|
.id = 0, /* we use this as a replacement for i2c-pxa */
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &palmz72_i2c_bus_data,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device palmz72_camera = {
|
|
|
|
.name = "soc-camera-pdrv",
|
|
|
|
.id = -1,
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &palmz72_iclink,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Here we request the camera GPIOs and configure them. We power up the camera
|
|
|
|
* module, deassert the reset pin, but put it into powerdown (low to no power
|
|
|
|
* consumption) mode. This allows us to later bring the module up fast. */
|
|
|
|
static struct gpio palmz72_camera_gpios[] = {
|
|
|
|
{ GPIO_NR_PALMZ72_CAM_POWER, GPIOF_INIT_HIGH,"Camera DVDD" },
|
|
|
|
{ GPIO_NR_PALMZ72_CAM_RESET, GPIOF_INIT_LOW, "Camera RESET" },
|
|
|
|
{ GPIO_NR_PALMZ72_CAM_PWDN, GPIOF_INIT_LOW, "Camera PWDN" },
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void __init palmz72_cam_gpio_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = gpio_request_array(ARRAY_AND_SIZE(palmz72_camera_gpios));
|
|
|
|
if (!ret)
|
|
|
|
gpio_free_array(ARRAY_AND_SIZE(palmz72_camera_gpios));
|
|
|
|
else
|
|
|
|
printk(KERN_ERR "Camera GPIO init failed!\n");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init palmz72_camera_init(void)
|
|
|
|
{
|
|
|
|
palmz72_cam_gpio_init();
|
|
|
|
pxa_set_camera_info(&palmz72_pxacamera_platform_data);
|
i2c: gpio: Convert to use descriptors
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>
2017-09-10 07:30:46 +08:00
|
|
|
gpiod_add_lookup_table(&palmz72_i2c_gpiod_table);
|
2011-01-13 18:45:30 +08:00
|
|
|
platform_device_register(&palmz72_i2c_bus_device);
|
|
|
|
platform_device_register(&palmz72_camera);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline void palmz72_camera_init(void) {}
|
|
|
|
#endif
|
|
|
|
|
2008-08-29 22:47:52 +08:00
|
|
|
/******************************************************************************
|
|
|
|
* Machine init
|
|
|
|
******************************************************************************/
|
|
|
|
static void __init palmz72_init(void)
|
|
|
|
{
|
|
|
|
pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config));
|
2009-11-09 13:34:08 +08:00
|
|
|
pxa_set_ffuart_info(NULL);
|
|
|
|
pxa_set_btuart_info(NULL);
|
|
|
|
pxa_set_stuart_info(NULL);
|
|
|
|
|
2010-07-13 14:16:45 +08:00
|
|
|
palm27x_mmc_init(GPIO_NR_PALMZ72_SD_DETECT_N, GPIO_NR_PALMZ72_SD_RO,
|
|
|
|
GPIO_NR_PALMZ72_SD_POWER_N, 1);
|
|
|
|
palm27x_lcd_init(-1, &palm_320x320_lcd_mode);
|
|
|
|
palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N,
|
|
|
|
GPIO_NR_PALMZ72_USB_PULLUP, 0);
|
|
|
|
palm27x_irda_init(GPIO_NR_PALMZ72_IR_DISABLE);
|
|
|
|
palm27x_ac97_init(PALMZ72_BAT_MIN_VOLTAGE, PALMZ72_BAT_MAX_VOLTAGE,
|
|
|
|
-1, 113);
|
|
|
|
palm27x_pwm_init(-1, -1);
|
|
|
|
palm27x_power_init(-1, -1);
|
|
|
|
palm27x_pmic_init();
|
|
|
|
palmz72_kpc_init();
|
|
|
|
palmz72_leds_init();
|
2011-01-13 18:45:30 +08:00
|
|
|
palmz72_camera_init();
|
2008-08-29 22:47:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MACHINE_START(PALMZ72, "Palm Zire72")
|
2011-07-06 10:38:15 +08:00
|
|
|
.atag_offset = 0x100,
|
2010-10-11 08:20:19 +08:00
|
|
|
.map_io = pxa27x_map_io,
|
2012-01-04 06:53:48 +08:00
|
|
|
.nr_irqs = PXA_NR_IRQS,
|
2008-08-29 22:47:52 +08:00
|
|
|
.init_irq = pxa27x_init_irq,
|
2011-05-18 21:30:04 +08:00
|
|
|
.handle_irq = pxa27x_handle_irq,
|
2012-11-09 03:40:59 +08:00
|
|
|
.init_time = pxa_timer_init,
|
2011-11-04 22:15:53 +08:00
|
|
|
.init_machine = palmz72_init,
|
|
|
|
.restart = pxa_restart,
|
2008-08-29 22:47:52 +08:00
|
|
|
MACHINE_END
|