Commit e6ff514e authored by Arnd Bergmann's avatar Arnd Bergmann

Merge tag 'omap-for-v4.20/omap1-signed' of...

Merge tag 'omap-for-v4.20/omap1-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into next/soc

A series of omap1 gpio changes for ams-delta

Janusz Krzysztofik has cleaned up ams-delta gpio usage along with
generic gpio framework improvments. This series contains the omap1
specific clean-up for ams-delta modem and unused gpios.

Note that this conflicts with the gpio-omap changes queued into
an immutable gpio branch ib-omap for the gpio-omap.h header file.
The merge resolution is to drop the IS_BUILTIN(CONFIG_GPIO_OMAP)
section and keep the #endif tagged for __ASSEMBLER__.

* tag 'omap-for-v4.20/omap1-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap:
  ARM: OMAP1: ams-delta: Don't request unused GPIOs
  ARM: OMAP1: ams-delta-fiq: Use <linux/platform_data/gpio-omap.h>
  ARM: OMAP1: ams-delta: register MODEM device earlier
  ARM: OMAP1: ams-delta: initialize latch2 pins to safe values
  ARM: OMAP1: ams-delta: assign MODEM IRQ from GPIO descriptor
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parents 3a60f118 1137ceee
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/platform_data/ams-delta-fiq.h> #include <linux/platform_data/ams-delta-fiq.h>
#include <linux/platform_data/gpio-omap.h>
#include <asm/assembler.h> #include <asm/assembler.h>
#include <mach/board-ams-delta.h> #include <mach/board-ams-delta.h>
...@@ -24,17 +25,10 @@ ...@@ -24,17 +25,10 @@
#include "soc.h" #include "soc.h"
/* /*
* GPIO related definitions, copied from arch/arm/plat-omap/gpio.c. * OMAP1510 GPIO related symbol copied from arch/arm/mach-omap1/gpio15xx.c.
* Unfortunately, those were not placed in a separate header file. * Unfortunately, it was not placed in a separate header file.
*/ */
#define OMAP1510_GPIO_BASE 0xFFFCE000 #define OMAP1510_GPIO_BASE 0xFFFCE000
#define OMAP1510_GPIO_DATA_INPUT 0x00
#define OMAP1510_GPIO_DATA_OUTPUT 0x04
#define OMAP1510_GPIO_DIR_CONTROL 0x08
#define OMAP1510_GPIO_INT_CONTROL 0x0c
#define OMAP1510_GPIO_INT_MASK 0x10
#define OMAP1510_GPIO_INT_STATUS 0x14
#define OMAP1510_GPIO_PIN_CONTROL 0x18
/* GPIO register bitmasks */ /* GPIO register bitmasks */
#define KEYBRD_DATA_MASK (0x1 << AMS_DELTA_GPIO_PIN_KEYBRD_DATA) #define KEYBRD_DATA_MASK (0x1 << AMS_DELTA_GPIO_PIN_KEYBRD_DATA)
......
...@@ -250,39 +250,6 @@ static struct platform_device latch2_gpio_device = { ...@@ -250,39 +250,6 @@ static struct platform_device latch2_gpio_device = {
#define LATCH2_PIN_HOOKFLASH1 14 #define LATCH2_PIN_HOOKFLASH1 14
#define LATCH2_PIN_HOOKFLASH2 15 #define LATCH2_PIN_HOOKFLASH2 15
static const struct gpio latch_gpios[] __initconst = {
{
.gpio = LATCH1_GPIO_BASE + 6,
.flags = GPIOF_OUT_INIT_LOW,
.label = "dockit1",
},
{
.gpio = LATCH1_GPIO_BASE + 7,
.flags = GPIOF_OUT_INIT_LOW,
.label = "dockit2",
},
{
.gpio = AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
.flags = GPIOF_OUT_INIT_LOW,
.label = "scard_rstin",
},
{
.gpio = AMS_DELTA_GPIO_PIN_SCARD_CMDVCC,
.flags = GPIOF_OUT_INIT_LOW,
.label = "scard_cmdvcc",
},
{
.gpio = AMS_DELTA_LATCH2_GPIO_BASE + 14,
.flags = GPIOF_OUT_INIT_LOW,
.label = "hookflash1",
},
{
.gpio = AMS_DELTA_LATCH2_GPIO_BASE + 15,
.flags = GPIOF_OUT_INIT_LOW,
.label = "hookflash2",
},
};
static struct regulator_consumer_supply modem_nreset_consumers[] = { static struct regulator_consumer_supply modem_nreset_consumers[] = {
REGULATOR_SUPPLY("RESET#", "serial8250.1"), REGULATOR_SUPPLY("RESET#", "serial8250.1"),
REGULATOR_SUPPLY("POR", "cx20442-codec"), REGULATOR_SUPPLY("POR", "cx20442-codec"),
...@@ -321,20 +288,6 @@ struct modem_private_data { ...@@ -321,20 +288,6 @@ struct modem_private_data {
static struct modem_private_data modem_priv; static struct modem_private_data modem_priv;
void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
{
int bit = 0;
u16 bitpos = 1 << bit;
for (; bit < ngpio; bit++, bitpos = bitpos << 1) {
if (!(mask & bitpos))
continue;
else
gpio_set_value(base + bit, (value & bitpos) != 0);
}
}
EXPORT_SYMBOL(ams_delta_latch_write);
static struct resource ams_delta_nand_resources[] = { static struct resource ams_delta_nand_resources[] = {
[0] = { [0] = {
.start = OMAP1_MPUIO_BASE, .start = OMAP1_MPUIO_BASE,
...@@ -630,6 +583,28 @@ static struct gpiod_hog ams_delta_gpio_hogs[] = { ...@@ -630,6 +583,28 @@ static struct gpiod_hog ams_delta_gpio_hogs[] = {
{}, {},
}; };
static struct plat_serial8250_port ams_delta_modem_ports[];
/*
* Obtain MODEM IRQ GPIO descriptor using its hardware pin
* number and assign related IRQ number to the MODEM port.
* Keep the GPIO descriptor open so nobody steps in.
*/
static void __init modem_assign_irq(struct gpio_chip *chip)
{
struct gpio_desc *gpiod;
gpiod = gpiochip_request_own_desc(chip, AMS_DELTA_GPIO_PIN_MODEM_IRQ,
"modem_irq");
if (IS_ERR(gpiod)) {
pr_err("%s: modem IRQ GPIO request failed (%ld)\n", __func__,
PTR_ERR(gpiod));
} else {
gpiod_direction_input(gpiod);
ams_delta_modem_ports[0].irq = gpiod_to_irq(gpiod);
}
}
/* /*
* The purpose of this function is to take care of proper initialization of * The purpose of this function is to take care of proper initialization of
* devices and data structures which depend on GPIO lines provided by OMAP GPIO * devices and data structures which depend on GPIO lines provided by OMAP GPIO
...@@ -649,7 +624,47 @@ static void __init omap_gpio_deps_init(void) ...@@ -649,7 +624,47 @@ static void __init omap_gpio_deps_init(void)
return; return;
} }
/*
* Start with FIQ initialization as it may have to request
* and release successfully each OMAP GPIO pin in turn.
*/
ams_delta_init_fiq(chip, &ams_delta_serio_device); ams_delta_init_fiq(chip, &ams_delta_serio_device);
modem_assign_irq(chip);
}
/*
* Initialize latch2 pins with values which are safe for dependent on-board
* devices or useful for their successull initialization even before GPIO
* driver takes control over the latch pins:
* - LATCH2_PIN_LCD_VBLEN = 0
* - LATCH2_PIN_LCD_NDISP = 0 Keep LCD device powered off before its
* driver takes control over it.
* - LATCH2_PIN_NAND_NCE = 0
* - LATCH2_PIN_NAND_NWP = 0 Keep NAND device down and write-
* protected before its driver takes
* control over it.
* - LATCH2_PIN_KEYBRD_PWR = 0 Keep keyboard powered off before serio
* driver takes control over it.
* - LATCH2_PIN_KEYBRD_DATAOUT = 0 Keep low to avoid corruption of first
* byte of data received from attached
* keyboard when serio device is probed;
* the pin is also hogged low by the latch2
* GPIO driver as soon as it is ready.
* - LATCH2_PIN_MODEM_NRESET = 1 Enable voice MODEM device, allowing for
* its successful probe even before a
* regulator it depends on, which in turn
* takes control over the pin, is set up.
* - LATCH2_PIN_MODEM_CODEC = 1 Attach voice MODEM CODEC data port
* to the MODEM so the CODEC is under
* control even if audio driver doesn't
* take it over.
*/
static void __init ams_delta_latch2_init(void)
{
u16 latch2 = 1 << LATCH2_PIN_MODEM_NRESET | 1 << LATCH2_PIN_MODEM_CODEC;
__raw_writew(latch2, LATCH2_VIRT);
} }
static void __init ams_delta_init(void) static void __init ams_delta_init(void)
...@@ -673,6 +688,7 @@ static void __init ams_delta_init(void) ...@@ -673,6 +688,7 @@ static void __init ams_delta_init(void)
omap_cfg_reg(J18_1610_CAM_D7); omap_cfg_reg(J18_1610_CAM_D7);
omap_gpio_deps_init(); omap_gpio_deps_init();
ams_delta_latch2_init();
gpiod_add_hogs(ams_delta_gpio_hogs); gpiod_add_hogs(ams_delta_gpio_hogs);
omap_serial_init(); omap_serial_init();
...@@ -813,7 +829,6 @@ static void __init ams_delta_led_init(struct gpio_chip *chip) ...@@ -813,7 +829,6 @@ static void __init ams_delta_led_init(struct gpio_chip *chip)
static int __init ams_delta_gpio_init(void) static int __init ams_delta_gpio_init(void)
{ {
struct gpio_chip *chip; struct gpio_chip *chip;
int err;
if (!machine_is_ams_delta()) if (!machine_is_ams_delta())
return -ENODEV; return -ENODEV;
...@@ -824,11 +839,7 @@ static int __init ams_delta_gpio_init(void) ...@@ -824,11 +839,7 @@ static int __init ams_delta_gpio_init(void)
else else
ams_delta_led_init(chip); ams_delta_led_init(chip);
err = gpio_request_array(latch_gpios, ARRAY_SIZE(latch_gpios)); return 0;
if (err)
pr_err("Couldn't take over latch1/latch2 GPIO pins\n");
return err;
} }
device_initcall_sync(ams_delta_gpio_init); device_initcall_sync(ams_delta_gpio_init);
...@@ -844,33 +855,44 @@ static int __init modem_nreset_init(void) ...@@ -844,33 +855,44 @@ static int __init modem_nreset_init(void)
} }
/*
* This function expects MODEM IRQ number already assigned to the port
* and fails if it's not.
* The MODEM device requires its RESET# pin kept high during probe.
* That requirement can be fulfilled in several ways:
* - with a descriptor of already functional modem_nreset regulator
* assigned to the MODEM private data,
* - with the regulator not yet controlled by modem_pm function but
* already enabled by default on probe,
* - before the modem_nreset regulator is probed, with the pin already
* set high explicitly.
* The last one is already guaranteed by ams_delta_latch2_init() called
* from machine_init.
* In order to avoid taking over ttyS0 device slot, the MODEM device
* should be registered after OMAP serial ports. Since those ports
* are registered at arch_initcall, this function can be called safely
* at arch_initcall_sync earliest.
*/
static int __init ams_delta_modem_init(void) static int __init ams_delta_modem_init(void)
{ {
int err; int err;
omap_cfg_reg(M14_1510_GPIO2); if (!machine_is_ams_delta())
ams_delta_modem_ports[0].irq = return -ENODEV;
gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem"); if (ams_delta_modem_ports[0].irq < 0)
if (err) { return ams_delta_modem_ports[0].irq;
pr_err("Couldn't request gpio pin for modem\n");
return err; omap_cfg_reg(M14_1510_GPIO2);
}
gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
/* Initialize the modem_nreset regulator consumer before use */ /* Initialize the modem_nreset regulator consumer before use */
modem_priv.regulator = ERR_PTR(-ENODEV); modem_priv.regulator = ERR_PTR(-ENODEV);
ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
AMS_DELTA_LATCH2_MODEM_CODEC);
err = platform_device_register(&ams_delta_modem_device); err = platform_device_register(&ams_delta_modem_device);
if (err)
gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
return err; return err;
} }
arch_initcall_sync(ams_delta_modem_init);
static int __init late_init(void) static int __init late_init(void)
{ {
...@@ -880,10 +902,6 @@ static int __init late_init(void) ...@@ -880,10 +902,6 @@ static int __init late_init(void)
if (err) if (err)
return err; return err;
err = ams_delta_modem_init();
if (err)
return err;
/* /*
* Once the modem device is registered, the modem_nreset * Once the modem device is registered, the modem_nreset
* regulator can be requested on behalf of that device. * regulator can be requested on behalf of that device.
...@@ -898,7 +916,6 @@ static int __init late_init(void) ...@@ -898,7 +916,6 @@ static int __init late_init(void)
unregister: unregister:
platform_device_unregister(&ams_delta_modem_device); platform_device_unregister(&ams_delta_modem_device);
gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
return err; return err;
} }
......
...@@ -59,13 +59,6 @@ ...@@ -59,13 +59,6 @@
#define AMS_DELTA_LATCH2_GPIO_BASE AMS_DELTA_GPIO_PIN_LCD_VBLEN #define AMS_DELTA_LATCH2_GPIO_BASE AMS_DELTA_GPIO_PIN_LCD_VBLEN
#define AMS_DELTA_LATCH2_NGPIO 16 #define AMS_DELTA_LATCH2_NGPIO 16
#ifndef __ASSEMBLY__
void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value);
#define ams_delta_latch2_write(mask, value) \
ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \
AMS_DELTA_LATCH2_NGPIO, (mask), (value))
#endif
#endif /* CONFIG_MACH_AMS_DELTA */ #endif /* CONFIG_MACH_AMS_DELTA */
#endif /* __ASM_ARCH_OMAP_AMS_DELTA_H */ #endif /* __ASM_ARCH_OMAP_AMS_DELTA_H */
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
#ifndef __ASM_ARCH_OMAP_GPIO_H #ifndef __ASM_ARCH_OMAP_GPIO_H
#define __ASM_ARCH_OMAP_GPIO_H #define __ASM_ARCH_OMAP_GPIO_H
#ifndef __ASSEMBLER__
#include <linux/io.h> #include <linux/io.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#endif
#define OMAP1_MPUIO_BASE 0xfffb5000 #define OMAP1_MPUIO_BASE 0xfffb5000
...@@ -157,6 +159,7 @@ ...@@ -157,6 +159,7 @@
#define OMAP_MPUIO(nr) (OMAP_MAX_GPIO_LINES + (nr)) #define OMAP_MPUIO(nr) (OMAP_MAX_GPIO_LINES + (nr))
#define OMAP_GPIO_IS_MPUIO(nr) ((nr) >= OMAP_MAX_GPIO_LINES) #define OMAP_GPIO_IS_MPUIO(nr) ((nr) >= OMAP_MAX_GPIO_LINES)
#ifndef __ASSEMBLER__
struct omap_gpio_reg_offs { struct omap_gpio_reg_offs {
u16 revision; u16 revision;
u16 direction; u16 direction;
...@@ -215,5 +218,6 @@ static inline void omap2_gpio_resume_after_idle(void) ...@@ -215,5 +218,6 @@ static inline void omap2_gpio_resume_after_idle(void)
{ {
} }
#endif #endif
#endif /* __ASSEMBLER__ */
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment