2010-02-15 07:16:01 +07:00
|
|
|
/*
|
|
|
|
* arch/arm/mach-ep93xx/snappercl15.c
|
|
|
|
* Bluewater Systems Snapper CL15 system module
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Bluewater Systems Ltd
|
2011-06-15 11:45:36 +07:00
|
|
|
* Author: Ryan Mallon
|
2010-02-15 07:16:01 +07:00
|
|
|
*
|
|
|
|
* NAND code adapted from driver by:
|
|
|
|
* Andre Renaud <andre@bluewatersys.com>
|
|
|
|
* James R. McKaskill
|
|
|
|
*
|
|
|
|
* 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/platform_device.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/fb.h>
|
|
|
|
|
|
|
|
#include <linux/mtd/partitions.h>
|
2017-08-04 22:29:10 +07:00
|
|
|
#include <linux/mtd/rawnand.h>
|
2010-02-15 07:16:01 +07:00
|
|
|
|
|
|
|
#include <mach/hardware.h>
|
2012-08-24 20:12:11 +07:00
|
|
|
#include <linux/platform_data/video-ep93xx.h>
|
2011-09-22 14:07:00 +07:00
|
|
|
#include <mach/gpio-ep93xx.h>
|
2010-02-15 07:16:01 +07:00
|
|
|
|
|
|
|
#include <asm/mach-types.h>
|
|
|
|
#include <asm/mach/arch.h>
|
|
|
|
|
2012-01-11 05:06:08 +07:00
|
|
|
#include "soc.h"
|
|
|
|
|
2010-02-15 07:16:01 +07:00
|
|
|
#define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M)
|
|
|
|
|
|
|
|
#define SNAPPERCL15_NAND_WPN (1 << 8) /* Write protect (active low) */
|
|
|
|
#define SNAPPERCL15_NAND_ALE (1 << 9) /* Address latch */
|
|
|
|
#define SNAPPERCL15_NAND_CLE (1 << 10) /* Command latch */
|
|
|
|
#define SNAPPERCL15_NAND_CEN (1 << 11) /* Chip enable (active low) */
|
|
|
|
#define SNAPPERCL15_NAND_RDY (1 << 14) /* Device ready */
|
|
|
|
|
|
|
|
#define NAND_CTRL_ADDR(chip) (chip->IO_ADDR_W + 0x40)
|
|
|
|
|
|
|
|
static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
|
|
|
|
unsigned int ctrl)
|
|
|
|
{
|
2015-12-01 18:02:58 +07:00
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
2010-02-15 07:16:01 +07:00
|
|
|
static u16 nand_state = SNAPPERCL15_NAND_WPN;
|
|
|
|
u16 set;
|
|
|
|
|
|
|
|
if (ctrl & NAND_CTRL_CHANGE) {
|
|
|
|
set = SNAPPERCL15_NAND_CEN | SNAPPERCL15_NAND_WPN;
|
|
|
|
|
|
|
|
if (ctrl & NAND_NCE)
|
|
|
|
set &= ~SNAPPERCL15_NAND_CEN;
|
|
|
|
if (ctrl & NAND_CLE)
|
|
|
|
set |= SNAPPERCL15_NAND_CLE;
|
|
|
|
if (ctrl & NAND_ALE)
|
|
|
|
set |= SNAPPERCL15_NAND_ALE;
|
|
|
|
|
|
|
|
nand_state &= ~(SNAPPERCL15_NAND_CEN |
|
|
|
|
SNAPPERCL15_NAND_CLE |
|
|
|
|
SNAPPERCL15_NAND_ALE);
|
|
|
|
nand_state |= set;
|
|
|
|
__raw_writew(nand_state, NAND_CTRL_ADDR(chip));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd != NAND_CMD_NONE)
|
|
|
|
__raw_writew((cmd & 0xff) | nand_state, chip->IO_ADDR_W);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snappercl15_nand_dev_ready(struct mtd_info *mtd)
|
|
|
|
{
|
2015-12-01 18:02:58 +07:00
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
2010-02-15 07:16:01 +07:00
|
|
|
|
|
|
|
return !!(__raw_readw(NAND_CTRL_ADDR(chip)) & SNAPPERCL15_NAND_RDY);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct mtd_partition snappercl15_nand_parts[] = {
|
|
|
|
{
|
|
|
|
.name = "Kernel",
|
|
|
|
.offset = 0,
|
|
|
|
.size = SZ_2M,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "Filesystem",
|
|
|
|
.offset = MTDPART_OFS_APPEND,
|
|
|
|
.size = MTDPART_SIZ_FULL,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_nand_data snappercl15_nand_data = {
|
|
|
|
.chip = {
|
|
|
|
.nr_chips = 1,
|
|
|
|
.partitions = snappercl15_nand_parts,
|
|
|
|
.nr_partitions = ARRAY_SIZE(snappercl15_nand_parts),
|
|
|
|
.chip_delay = 25,
|
|
|
|
},
|
|
|
|
.ctrl = {
|
|
|
|
.dev_ready = snappercl15_nand_dev_ready,
|
|
|
|
.cmd_ctrl = snappercl15_nand_cmd_ctrl,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource snappercl15_nand_resource[] = {
|
|
|
|
{
|
|
|
|
.start = SNAPPERCL15_NAND_BASE,
|
|
|
|
.end = SNAPPERCL15_NAND_BASE + SZ_4K - 1,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device snappercl15_nand_device = {
|
|
|
|
.name = "gen_nand",
|
|
|
|
.id = -1,
|
|
|
|
.dev.platform_data = &snappercl15_nand_data,
|
|
|
|
.resource = snappercl15_nand_resource,
|
|
|
|
.num_resources = ARRAY_SIZE(snappercl15_nand_resource),
|
|
|
|
};
|
|
|
|
|
2010-03-19 00:04:06 +07:00
|
|
|
static struct ep93xx_eth_data __initdata snappercl15_eth_data = {
|
2010-02-15 07:16:01 +07:00
|
|
|
.phy_id = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct i2c_board_info __initdata snappercl15_i2c_data[] = {
|
|
|
|
{
|
|
|
|
/* Audio codec */
|
|
|
|
I2C_BOARD_INFO("tlv320aic23", 0x1a),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-03-19 00:04:06 +07:00
|
|
|
static struct ep93xxfb_mach_info __initdata snappercl15_fb_info = {
|
2010-02-15 07:16:01 +07:00
|
|
|
};
|
|
|
|
|
2011-09-11 16:28:55 +07:00
|
|
|
static struct platform_device snappercl15_audio_device = {
|
|
|
|
.name = "snappercl15-audio",
|
|
|
|
.id = -1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void __init snappercl15_register_audio(void)
|
|
|
|
{
|
|
|
|
ep93xx_register_i2s();
|
|
|
|
platform_device_register(&snappercl15_audio_device);
|
|
|
|
}
|
|
|
|
|
2010-02-15 07:16:01 +07:00
|
|
|
static void __init snappercl15_init_machine(void)
|
|
|
|
{
|
|
|
|
ep93xx_init_devices();
|
|
|
|
ep93xx_register_eth(&snappercl15_eth_data, 1);
|
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 06:30:46 +07:00
|
|
|
ep93xx_register_i2c(snappercl15_i2c_data,
|
2010-02-15 07:16:01 +07:00
|
|
|
ARRAY_SIZE(snappercl15_i2c_data));
|
|
|
|
ep93xx_register_fb(&snappercl15_fb_info);
|
2011-09-11 16:28:55 +07:00
|
|
|
snappercl15_register_audio();
|
2010-02-15 07:16:01 +07:00
|
|
|
platform_device_register(&snappercl15_nand_device);
|
|
|
|
}
|
|
|
|
|
|
|
|
MACHINE_START(SNAPPER_CL15, "Bluewater Systems Snapper CL15")
|
2011-06-15 11:45:36 +07:00
|
|
|
/* Maintainer: Ryan Mallon */
|
2011-07-06 09:38:11 +07:00
|
|
|
.atag_offset = 0x100,
|
2010-02-15 07:16:01 +07:00
|
|
|
.map_io = ep93xx_map_io,
|
|
|
|
.init_irq = ep93xx_init_irq,
|
2012-11-09 02:40:59 +07:00
|
|
|
.init_time = ep93xx_timer_init,
|
2010-02-15 07:16:01 +07:00
|
|
|
.init_machine = snappercl15_init_machine,
|
2012-04-26 09:05:15 +07:00
|
|
|
.init_late = ep93xx_init_late,
|
2011-11-05 16:54:14 +07:00
|
|
|
.restart = ep93xx_restart,
|
2010-02-15 07:16:01 +07:00
|
|
|
MACHINE_END
|