477 lines
12 KiB
C
477 lines
12 KiB
C
/*
|
|
* (c) 2010 STMicroelectronics Limited
|
|
*
|
|
* Author: Pawel Moll <pawel.moll@st.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.
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/ata_platform.h>
|
|
#include <linux/mtd/nand.h>
|
|
#include <linux/mtd/partitions.h>
|
|
#include <linux/stm/device.h>
|
|
#include <linux/stm/sysconf.h>
|
|
#include <linux/stm/emi.h>
|
|
#include <linux/stm/stx7200.h>
|
|
#include <asm/irq-ilc.h>
|
|
|
|
|
|
|
|
/* EMI resources ---------------------------------------------------------- */
|
|
|
|
static int __initdata stx7200_emi_bank_configured[EMI_BANKS];
|
|
|
|
static void stx7200_emi_power(struct stm_device_state *device_state,
|
|
enum stm_device_power_state power)
|
|
{
|
|
int i;
|
|
int value = (power == stm_device_power_on) ? 0 : 1;
|
|
|
|
stm_device_sysconf_write(device_state, "EMI_PWR", value);
|
|
for (i = 5; i; --i) {
|
|
if (stm_device_sysconf_read(device_state, "EMI_ACK")
|
|
== value)
|
|
break;
|
|
mdelay(10);
|
|
}
|
|
|
|
return;
|
|
}
|
|
static struct platform_device stx7200_emi = {
|
|
.name = "emi",
|
|
.id = -1,
|
|
.num_resources = 2,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0, 128 * 1024 * 1024),
|
|
STM_PLAT_RESOURCE_MEM(0xfdf00000, 0x874),
|
|
},
|
|
.dev.platform_data = &(struct stm_device_config){
|
|
.sysconfs_num = 2,
|
|
.sysconfs = (struct stm_device_sysconf []){
|
|
STM_DEVICE_SYS_CFG(32, 1, 1, "EMI_PWR"),
|
|
STM_DEVICE_SYS_STA(8, 1, 1, "EMI_ACK"),
|
|
},
|
|
.power = stx7200_emi_power,
|
|
}
|
|
};
|
|
|
|
|
|
|
|
/* PATA resources --------------------------------------------------------- */
|
|
|
|
/* EMI A20 = CS1 (active low)
|
|
* EMI A21 = CS0 (active low)
|
|
* EMI A19 = DA2
|
|
* EMI A18 = DA1
|
|
* EMI A17 = DA0 */
|
|
static struct resource stx7200_pata_resources[] = {
|
|
/* I/O base: CS1=N, CS0=A */
|
|
[0] = STM_PLAT_RESOURCE_MEM(1 << 20, 8 << 17),
|
|
/* CTL base: CS1=A, CS0=N, DA2=A, DA1=A, DA0=N */
|
|
[1] = STM_PLAT_RESOURCE_MEM((1 << 21) + (6 << 17), 4),
|
|
/* IRQ */
|
|
[2] = STM_PLAT_RESOURCE_IRQ(-1, -1),
|
|
};
|
|
|
|
static struct platform_device stx7200_pata_device = {
|
|
.name = "pata_platform",
|
|
.id = -1,
|
|
.num_resources = ARRAY_SIZE(stx7200_pata_resources),
|
|
.resource = stx7200_pata_resources,
|
|
.dev.platform_data = &(struct pata_platform_info) {
|
|
.ioport_shift = 17,
|
|
},
|
|
};
|
|
|
|
void __init stx7200_configure_pata(struct stx7200_pata_config *config)
|
|
{
|
|
unsigned long bank_base;
|
|
|
|
if (!config) {
|
|
BUG();
|
|
return;
|
|
}
|
|
|
|
BUG_ON(config->emi_bank < 0 || config->emi_bank >= EMI_BANKS);
|
|
BUG_ON(stx7200_emi_bank_configured[config->emi_bank]);
|
|
stx7200_emi_bank_configured[config->emi_bank] = 1;
|
|
|
|
bank_base = emi_bank_base(config->emi_bank);
|
|
|
|
stx7200_pata_resources[0].start += bank_base;
|
|
stx7200_pata_resources[0].end += bank_base;
|
|
stx7200_pata_resources[1].start += bank_base;
|
|
stx7200_pata_resources[1].end += bank_base;
|
|
stx7200_pata_resources[2].start = config->irq;
|
|
stx7200_pata_resources[2].end = config->irq;
|
|
|
|
emi_config_pata(config->emi_bank, config->pc_mode);
|
|
|
|
platform_device_register(&stx7200_pata_device);
|
|
}
|
|
|
|
|
|
|
|
/* NAND Resources --------------------------------------------------------- */
|
|
|
|
static struct platform_device stx7200_nand_emi_device = {
|
|
.name = "stm-nand-emi",
|
|
.dev.platform_data = &(struct stm_plat_nand_emi_data) {
|
|
},
|
|
};
|
|
|
|
static struct platform_device stx7200_nand_flex_device = {
|
|
.num_resources = 2,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM_NAMED("flex_mem", 0xFDF01000, 0x1000),
|
|
STM_PLAT_RESOURCE_IRQ(ILC_IRQ(123), -1),
|
|
},
|
|
.dev.platform_data = &(struct stm_plat_nand_flex_data) {
|
|
},
|
|
};
|
|
|
|
void __init stx7200_configure_nand(struct stm_nand_config *config)
|
|
{
|
|
struct stm_plat_nand_flex_data *flex_data;
|
|
struct stm_plat_nand_emi_data *emi_data;
|
|
|
|
switch (config->driver) {
|
|
case stm_nand_emi:
|
|
/* Configure device for stm-nand-emi driver */
|
|
emi_data = stx7200_nand_emi_device.dev.platform_data;
|
|
emi_data->nr_banks = config->nr_banks;
|
|
emi_data->banks = config->banks;
|
|
emi_data->emi_rbn_gpio = config->rbn.emi_gpio;
|
|
platform_device_register(&stx7200_nand_emi_device);
|
|
break;
|
|
case stm_nand_flex:
|
|
case stm_nand_afm:
|
|
/* Configure device for stm-nand-flex/afm driver */
|
|
flex_data = stx7200_nand_flex_device.dev.platform_data;
|
|
flex_data->nr_banks = config->nr_banks;
|
|
flex_data->banks = config->banks;
|
|
flex_data->flex_rbn_connected = config->rbn.flex_connected;
|
|
stx7200_nand_flex_device.name =
|
|
(config->driver == stm_nand_flex) ?
|
|
"stm-nand-flex" : "stm-nand-afm";
|
|
platform_device_register(&stx7200_nand_flex_device);
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
/* FDMA resources --------------------------------------------------------- */
|
|
|
|
static struct stm_plat_fdma_fw_regs stm_fdma_firmware_7200 = {
|
|
.rev_id = 0x8000 + (0x000 << 2), /* 0x8000 */
|
|
.cmd_statn = 0x8000 + (0x450 << 2), /* 0x9140 */
|
|
.req_ctln = 0x8000 + (0x460 << 2), /* 0x9180 */
|
|
.ptrn = 0x8000 + (0x560 << 2), /* 0x9580 */
|
|
.cntn = 0x8000 + (0x562 << 2), /* 0x9588 */
|
|
.saddrn = 0x8000 + (0x563 << 2), /* 0x958c */
|
|
.daddrn = 0x8000 + (0x564 << 2), /* 0x9590 */
|
|
};
|
|
|
|
static struct stm_plat_fdma_hw stx7200_fdma_hw = {
|
|
.slim_regs = {
|
|
.id = 0x0000 + (0x000 << 2), /* 0x0000 */
|
|
.ver = 0x0000 + (0x001 << 2), /* 0x0004 */
|
|
.en = 0x0000 + (0x002 << 2), /* 0x0008 */
|
|
.clk_gate = 0x0000 + (0x003 << 2), /* 0x000c */
|
|
},
|
|
.dmem = {
|
|
.offset = 0x8000,
|
|
.size = 0x800 << 2, /* 2048 * 4 = 8192 */
|
|
},
|
|
.periph_regs = {
|
|
.sync_reg = 0x8000 + (0xfe2 << 2), /* 0xbf88 */
|
|
.cmd_sta = 0x8000 + (0xff0 << 2), /* 0xbfc0 */
|
|
.cmd_set = 0x8000 + (0xff1 << 2), /* 0xbfc4 */
|
|
.cmd_clr = 0x8000 + (0xff2 << 2), /* 0xbfc8 */
|
|
.cmd_mask = 0x8000 + (0xff3 << 2), /* 0xbfcc */
|
|
.int_sta = 0x8000 + (0xff4 << 2), /* 0xbfd0 */
|
|
.int_set = 0x8000 + (0xff5 << 2), /* 0xbfd4 */
|
|
.int_clr = 0x8000 + (0xff6 << 2), /* 0xbfd8 */
|
|
.int_mask = 0x8000 + (0xff7 << 2), /* 0xbfdc */
|
|
},
|
|
.imem = {
|
|
.offset = 0xc000,
|
|
.size = 0x1000 << 2, /* 4096 * 4 = 16384 */
|
|
},
|
|
};
|
|
|
|
static struct stm_plat_fdma_data stx7200_fdma_platform_data = {
|
|
.hw = &stx7200_fdma_hw,
|
|
.fw = &stm_fdma_firmware_7200,
|
|
};
|
|
|
|
static struct platform_device stx7200_fdma_devices[] = {
|
|
{
|
|
.name = "stm-fdma",
|
|
.id = 0,
|
|
.num_resources = 2,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd810000, 0x10000),
|
|
STM_PLAT_RESOURCE_IRQ(ILC_IRQ(13), -1),
|
|
},
|
|
.dev.platform_data = &stx7200_fdma_platform_data,
|
|
}, {
|
|
.name = "stm-fdma",
|
|
.id = 1,
|
|
.num_resources = 2,
|
|
.resource = (struct resource[2]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd820000, 0x10000),
|
|
STM_PLAT_RESOURCE_IRQ(ILC_IRQ(15), -1),
|
|
},
|
|
.dev.platform_data = &stx7200_fdma_platform_data,
|
|
}
|
|
};
|
|
|
|
static struct platform_device stx7200_fdma_xbar_device = {
|
|
.name = "stm-fdma-xbar",
|
|
.id = -1,
|
|
.num_resources = 1,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd830000, 0x1000),
|
|
},
|
|
};
|
|
|
|
|
|
|
|
/* Hardware RNG resources ------------------------------------------------- */
|
|
|
|
static struct platform_device stx7200_rng_hwrandom_device = {
|
|
.name = "stm-hwrandom",
|
|
.id = -1,
|
|
.num_resources = 1,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfdb70000, 0x1000),
|
|
}
|
|
};
|
|
|
|
static struct platform_device stx7200_rng_devrandom_device = {
|
|
.name = "stm-rng",
|
|
.id = -1,
|
|
.num_resources = 1,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfdb70000, 0x1000),
|
|
}
|
|
};
|
|
|
|
|
|
|
|
/* PIO ports resources ---------------------------------------------------- */
|
|
|
|
static struct platform_device stx7200_pio_devices[] = {
|
|
[0] = {
|
|
.name = "stm-gpio",
|
|
.id = 0,
|
|
.num_resources = 2,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd020000, 0x100),
|
|
STM_PLAT_RESOURCE_IRQ(ILC_IRQ(96), -1),
|
|
},
|
|
},
|
|
[1] = {
|
|
.name = "stm-gpio",
|
|
.id = 1,
|
|
.num_resources = 2,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd021000, 0x100),
|
|
STM_PLAT_RESOURCE_IRQ(ILC_IRQ(97), -1),
|
|
},
|
|
},
|
|
[2] = {
|
|
.name = "stm-gpio",
|
|
.id = 2,
|
|
.num_resources = 2,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd022000, 0x100),
|
|
STM_PLAT_RESOURCE_IRQ(ILC_IRQ(98), -1),
|
|
},
|
|
},
|
|
[3] = {
|
|
.name = "stm-gpio",
|
|
.id = 3,
|
|
.num_resources = 2,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd023000, 0x100),
|
|
STM_PLAT_RESOURCE_IRQ(ILC_IRQ(99), -1),
|
|
},
|
|
},
|
|
[4] = {
|
|
.name = "stm-gpio",
|
|
.id = 4,
|
|
.num_resources = 2,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd024000, 0x100),
|
|
STM_PLAT_RESOURCE_IRQ(ILC_IRQ(100), -1),
|
|
},
|
|
},
|
|
[5] = {
|
|
.name = "stm-gpio",
|
|
.id = 5,
|
|
.num_resources = 2,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd025000, 0x100),
|
|
STM_PLAT_RESOURCE_IRQ(ILC_IRQ(101), -1),
|
|
},
|
|
},
|
|
[6] = {
|
|
.name = "stm-gpio",
|
|
.id = 6,
|
|
.num_resources = 2,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd026000, 0x100),
|
|
STM_PLAT_RESOURCE_IRQ(ILC_IRQ(102), -1),
|
|
},
|
|
},
|
|
[7] = {
|
|
.name = "stm-gpio",
|
|
.id = 7,
|
|
.num_resources = 2,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd027000, 0x100),
|
|
STM_PLAT_RESOURCE_IRQ(ILC_IRQ(103), -1),
|
|
},
|
|
},
|
|
};
|
|
|
|
static int stx7200_pio_config(unsigned gpio,
|
|
enum stm_pad_gpio_direction direction, int function, void *priv)
|
|
{
|
|
switch (direction) {
|
|
case stm_pad_gpio_direction_in:
|
|
BUG_ON(function != -1);
|
|
stm_gpio_direction(gpio, STM_GPIO_DIRECTION_IN);
|
|
break;
|
|
case stm_pad_gpio_direction_out:
|
|
BUG_ON(function < 0);
|
|
BUG_ON(function > 1);
|
|
stm_gpio_direction(gpio, function ?
|
|
STM_GPIO_DIRECTION_ALT_OUT :
|
|
STM_GPIO_DIRECTION_OUT);
|
|
break;
|
|
case stm_pad_gpio_direction_bidir:
|
|
BUG_ON(function < 0);
|
|
BUG_ON(function > 1);
|
|
stm_gpio_direction(gpio, function ?
|
|
STM_GPIO_DIRECTION_ALT_BIDIR :
|
|
STM_GPIO_DIRECTION_BIDIR);
|
|
break;
|
|
default:
|
|
BUG();
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
/* sysconf resources ------------------------------------------------------ */
|
|
|
|
static struct platform_device stx7200_sysconf_device = {
|
|
.name = "stm-sysconf",
|
|
.id = -1,
|
|
.num_resources = 1,
|
|
.resource = (struct resource[]) {
|
|
STM_PLAT_RESOURCE_MEM(0xfd704000, 0x1d4),
|
|
},
|
|
.dev.platform_data = &(struct stm_plat_sysconf_data) {
|
|
.groups_num = 3,
|
|
.groups = (struct stm_plat_sysconf_group []) {
|
|
PLAT_SYSCONF_GROUP(SYS_DEV, 0x000),
|
|
PLAT_SYSCONF_GROUP(SYS_STA, 0x008),
|
|
PLAT_SYSCONF_GROUP(SYS_CFG, 0x100),
|
|
},
|
|
},
|
|
};
|
|
|
|
|
|
|
|
/* Early initialisation-----------------------------------------------------*/
|
|
|
|
/* Initialise devices which are required early in the boot process. */
|
|
void __init stx7200_early_device_init(void)
|
|
{
|
|
struct sysconf_field *sc;
|
|
unsigned long devid;
|
|
unsigned long chip_revision;
|
|
|
|
/* Initialise PIO and sysconf drivers */
|
|
|
|
sysconf_early_init(&stx7200_sysconf_device, 1);
|
|
stm_gpio_early_init(stx7200_pio_devices,
|
|
ARRAY_SIZE(stx7200_pio_devices),
|
|
ILC_FIRST_IRQ + ILC_NR_IRQS);
|
|
stm_pad_init(ARRAY_SIZE(stx7200_pio_devices) * STM_GPIO_PINS_PER_PORT,
|
|
-1, 0, stx7200_pio_config);
|
|
|
|
sc = sysconf_claim(SYS_DEV, 0, 0, 31, "devid");
|
|
devid = sysconf_read(sc);
|
|
chip_revision = (devid >> 28) + 1;
|
|
boot_cpu_data.cut_major = chip_revision;
|
|
|
|
printk(KERN_INFO "STx7200 version %ld.x\n", chip_revision);
|
|
|
|
/* ClockgenB powers up with all the frequency synths bypassed.
|
|
* Enable them all here. Without this, USB 1.1 doesn't work,
|
|
* as it needs a 48MHz clock which is separate from the USB 2
|
|
* clock which is derived from the SATA clock. */
|
|
ctrl_outl(0, 0xFD701048);
|
|
|
|
/* Configure the ST40 RTC to source its clock from clockgenB.
|
|
* In theory this should be board specific, but so far nobody
|
|
* has ever done this. */
|
|
sc = sysconf_claim(SYS_CFG, 8, 1, 1, "rtc");
|
|
sysconf_write(sc, 1);
|
|
|
|
/* We haven't configured the LPC, so the sleep instruction may
|
|
* do bad things. Thus we disable it here. */
|
|
disable_hlt();
|
|
}
|
|
|
|
|
|
|
|
/* Pre-arch initialisation ------------------------------------------------ */
|
|
|
|
static int __init stx7200_postcore_setup(void)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(stx7200_pio_devices); i++)
|
|
platform_device_register(&stx7200_pio_devices[i]);
|
|
|
|
return platform_device_register(&stx7200_emi);
|
|
}
|
|
postcore_initcall(stx7200_postcore_setup);
|
|
|
|
|
|
|
|
/* Late initialisation ---------------------------------------------------- */
|
|
|
|
static struct platform_device *stx7200_devices[] __initdata = {
|
|
&stx7200_fdma_devices[0],
|
|
&stx7200_fdma_devices[1],
|
|
&stx7200_fdma_xbar_device,
|
|
&stx7200_sysconf_device,
|
|
&stx7200_rng_hwrandom_device,
|
|
&stx7200_rng_devrandom_device,
|
|
};
|
|
|
|
static int __init stx7200_devices_setup(void)
|
|
{
|
|
return platform_add_devices(stx7200_devices,
|
|
ARRAY_SIZE(stx7200_devices));
|
|
}
|
|
device_initcall(stx7200_devices_setup);
|