提交 22fc1db1 编写于 作者: N Nicolas Pitre

Merge branch 'for-np' of git://git.wormnet.eu/alex/ts78xx into orion/master

...@@ -1177,7 +1177,7 @@ CONFIG_RTC_DRV_S35390A=y ...@@ -1177,7 +1177,7 @@ CONFIG_RTC_DRV_S35390A=y
# CONFIG_RTC_DRV_DS1553 is not set # CONFIG_RTC_DRV_DS1553 is not set
# CONFIG_RTC_DRV_DS1742 is not set # CONFIG_RTC_DRV_DS1742 is not set
# CONFIG_RTC_DRV_STK17TA8 is not set # CONFIG_RTC_DRV_STK17TA8 is not set
# CONFIG_RTC_DRV_M48T86 is not set CONFIG_RTC_DRV_M48T86=y
# CONFIG_RTC_DRV_M48T59 is not set # CONFIG_RTC_DRV_M48T59 is not set
# CONFIG_RTC_DRV_V3020 is not set # CONFIG_RTC_DRV_V3020 is not set
......
...@@ -71,6 +71,7 @@ config MACH_WRT350N_V2 ...@@ -71,6 +71,7 @@ config MACH_WRT350N_V2
config MACH_TS78XX config MACH_TS78XX
bool "Technologic Systems TS-78xx" bool "Technologic Systems TS-78xx"
select PM
help help
Say 'Y' here if you want your kernel to support the Say 'Y' here if you want your kernel to support the
Technologic Systems TS-78xx platform. Technologic Systems TS-78xx platform.
......
#define FPGAID(_magic, _rev) ((_magic << 8) + _rev)
/*
* get yer id's from http://ts78xx.digriz.org.uk/
* do *not* make up your own or 'borrow' any!
*/
enum fpga_ids {
/* Technologic Systems */
TS7800_REV_B = FPGAID(0x00b480, 0x03),
};
struct fpga_device {
unsigned present:1;
unsigned init:1;
};
struct fpga_devices {
/* Technologic Systems */
struct fpga_device ts_rtc;
};
struct ts78xx_fpga_data {
unsigned int id;
int state;
struct fpga_devices supports;
};
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/sysfs.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mtd/physmap.h>
#include <linux/mv643xx_eth.h> #include <linux/mv643xx_eth.h>
#include <linux/ata_platform.h> #include <linux/ata_platform.h>
#include <linux/m48t86.h> #include <linux/m48t86.h>
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <mach/orion5x.h> #include <mach/orion5x.h>
#include "common.h" #include "common.h"
#include "mpp.h" #include "mpp.h"
#include "ts78xx-fpga.h"
/***************************************************************************** /*****************************************************************************
* TS-78xx Info * TS-78xx Info
...@@ -33,18 +34,11 @@ ...@@ -33,18 +34,11 @@
#define TS78XX_FPGA_REGS_VIRT_BASE 0xff900000 #define TS78XX_FPGA_REGS_VIRT_BASE 0xff900000
#define TS78XX_FPGA_REGS_SIZE SZ_1M #define TS78XX_FPGA_REGS_SIZE SZ_1M
#define TS78XX_FPGA_REGS_SYSCON_ID (TS78XX_FPGA_REGS_VIRT_BASE | 0x000) static struct ts78xx_fpga_data ts78xx_fpga = {
#define TS78XX_FPGA_REGS_SYSCON_LCDI (TS78XX_FPGA_REGS_VIRT_BASE | 0x004) .id = 0,
#define TS78XX_FPGA_REGS_SYSCON_LCDO (TS78XX_FPGA_REGS_VIRT_BASE | 0x008) .state = 1,
/* .supports = ... - populated by ts78xx_fpga_supports() */
#define TS78XX_FPGA_REGS_RTC_CTRL (TS78XX_FPGA_REGS_VIRT_BASE | 0x808) };
#define TS78XX_FPGA_REGS_RTC_DATA (TS78XX_FPGA_REGS_VIRT_BASE | 0x80c)
/*
* 512kB NOR flash Device
*/
#define TS78XX_NOR_BOOT_BASE 0xff800000
#define TS78XX_NOR_BOOT_SIZE SZ_512K
/***************************************************************************** /*****************************************************************************
* I/O Address Mapping * I/O Address Mapping
...@@ -65,73 +59,48 @@ void __init ts78xx_map_io(void) ...@@ -65,73 +59,48 @@ void __init ts78xx_map_io(void)
} }
/***************************************************************************** /*****************************************************************************
* 512kB NOR Boot Flash - the chip is a M25P40 * Ethernet
****************************************************************************/ ****************************************************************************/
static struct mtd_partition ts78xx_nor_boot_flash_resources[] = { static struct mv643xx_eth_platform_data ts78xx_eth_data = {
{ .phy_addr = MV643XX_ETH_PHY_ADDR(0),
.name = "ts-bootrom",
.offset = 0,
/* only the first 256kB is used */
.size = SZ_256K,
.mask_flags = MTD_WRITEABLE,
},
};
static struct physmap_flash_data ts78xx_nor_boot_flash_data = {
.width = 1,
.parts = ts78xx_nor_boot_flash_resources,
.nr_parts = ARRAY_SIZE(ts78xx_nor_boot_flash_resources),
};
static struct resource ts78xx_nor_boot_flash_resource = {
.flags = IORESOURCE_MEM,
.start = TS78XX_NOR_BOOT_BASE,
.end = TS78XX_NOR_BOOT_BASE + TS78XX_NOR_BOOT_SIZE - 1,
};
static struct platform_device ts78xx_nor_boot_flash = {
.name = "physmap-flash",
.id = -1,
.dev = {
.platform_data = &ts78xx_nor_boot_flash_data,
},
.num_resources = 1,
.resource = &ts78xx_nor_boot_flash_resource,
}; };
/***************************************************************************** /*****************************************************************************
* Ethernet * SATA
****************************************************************************/ ****************************************************************************/
static struct mv643xx_eth_platform_data ts78xx_eth_data = { static struct mv_sata_platform_data ts78xx_sata_data = {
.phy_addr = MV643XX_ETH_PHY_ADDR(0), .n_ports = 2,
}; };
/***************************************************************************** /*****************************************************************************
* RTC M48T86 - nicked^Wborrowed from arch/arm/mach-ep93xx/ts72xx.c * RTC M48T86 - nicked^Wborrowed from arch/arm/mach-ep93xx/ts72xx.c
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_RTC_DRV_M48T86 #ifdef CONFIG_RTC_DRV_M48T86
static unsigned char ts78xx_rtc_readbyte(unsigned long addr) #define TS_RTC_CTRL (TS78XX_FPGA_REGS_VIRT_BASE | 0x808)
#define TS_RTC_DATA (TS78XX_FPGA_REGS_VIRT_BASE | 0x80c)
static unsigned char ts78xx_ts_rtc_readbyte(unsigned long addr)
{ {
writeb(addr, TS78XX_FPGA_REGS_RTC_CTRL); writeb(addr, TS_RTC_CTRL);
return readb(TS78XX_FPGA_REGS_RTC_DATA); return readb(TS_RTC_DATA);
} }
static void ts78xx_rtc_writebyte(unsigned char value, unsigned long addr) static void ts78xx_ts_rtc_writebyte(unsigned char value, unsigned long addr)
{ {
writeb(addr, TS78XX_FPGA_REGS_RTC_CTRL); writeb(addr, TS_RTC_CTRL);
writeb(value, TS78XX_FPGA_REGS_RTC_DATA); writeb(value, TS_RTC_DATA);
} }
static struct m48t86_ops ts78xx_rtc_ops = { static struct m48t86_ops ts78xx_ts_rtc_ops = {
.readbyte = ts78xx_rtc_readbyte, .readbyte = ts78xx_ts_rtc_readbyte,
.writebyte = ts78xx_rtc_writebyte, .writebyte = ts78xx_ts_rtc_writebyte,
}; };
static struct platform_device ts78xx_rtc_device = { static struct platform_device ts78xx_ts_rtc_device = {
.name = "rtc-m48t86", .name = "rtc-m48t86",
.id = -1, .id = -1,
.dev = { .dev = {
.platform_data = &ts78xx_rtc_ops, .platform_data = &ts78xx_ts_rtc_ops,
}, },
.num_resources = 0, .num_resources = 0,
}; };
...@@ -146,59 +115,185 @@ static struct platform_device ts78xx_rtc_device = { ...@@ -146,59 +115,185 @@ static struct platform_device ts78xx_rtc_device = {
* TODO: track down a guinea pig without an RTC to see if we can work out a * TODO: track down a guinea pig without an RTC to see if we can work out a
* better RTC detection routine * better RTC detection routine
*/ */
static int __init ts78xx_rtc_init(void) static int ts78xx_ts_rtc_load(void)
{ {
unsigned char tmp_rtc0, tmp_rtc1; unsigned char tmp_rtc0, tmp_rtc1;
tmp_rtc0 = ts78xx_rtc_readbyte(126); tmp_rtc0 = ts78xx_ts_rtc_readbyte(126);
tmp_rtc1 = ts78xx_rtc_readbyte(127); tmp_rtc1 = ts78xx_ts_rtc_readbyte(127);
ts78xx_rtc_writebyte(0x00, 126); ts78xx_ts_rtc_writebyte(0x00, 126);
ts78xx_rtc_writebyte(0x55, 127); ts78xx_ts_rtc_writebyte(0x55, 127);
if (ts78xx_rtc_readbyte(127) == 0x55) { if (ts78xx_ts_rtc_readbyte(127) == 0x55) {
ts78xx_rtc_writebyte(0xaa, 127); ts78xx_ts_rtc_writebyte(0xaa, 127);
if (ts78xx_rtc_readbyte(127) == 0xaa if (ts78xx_ts_rtc_readbyte(127) == 0xaa
&& ts78xx_rtc_readbyte(126) == 0x00) { && ts78xx_ts_rtc_readbyte(126) == 0x00) {
ts78xx_rtc_writebyte(tmp_rtc0, 126); ts78xx_ts_rtc_writebyte(tmp_rtc0, 126);
ts78xx_rtc_writebyte(tmp_rtc1, 127); ts78xx_ts_rtc_writebyte(tmp_rtc1, 127);
platform_device_register(&ts78xx_rtc_device); if (ts78xx_fpga.supports.ts_rtc.init == 0) {
return 1; ts78xx_fpga.supports.ts_rtc.init = 1;
platform_device_register(&ts78xx_ts_rtc_device);
} else
platform_device_add(&ts78xx_ts_rtc_device);
return 0;
} }
} }
return 0; ts78xx_fpga.supports.ts_rtc.present = 0;
return -ENODEV;
}; };
static void ts78xx_ts_rtc_unload(void)
{
platform_device_del(&ts78xx_ts_rtc_device);
}
#else #else
static int __init ts78xx_rtc_init(void) static int ts78xx_ts_rtc_load(void)
{ {
return 0; return 0;
} }
static void ts78xx_ts_rtc_unload(void)
{
}
#endif #endif
/***************************************************************************** /*****************************************************************************
* SATA * FPGA 'hotplug' support code
****************************************************************************/ ****************************************************************************/
static struct mv_sata_platform_data ts78xx_sata_data = { static void ts78xx_fpga_devices_zero_init(void)
.n_ports = 2, {
ts78xx_fpga.supports.ts_rtc.init = 0;
}
static void ts78xx_fpga_supports(void)
{
/* TODO: put this 'table' into ts78xx-fpga.h */
switch (ts78xx_fpga.id) {
case TS7800_REV_B:
ts78xx_fpga.supports.ts_rtc.present = 1;
break;
default:
ts78xx_fpga.supports.ts_rtc.present = 0;
}
}
static int ts78xx_fpga_load_devices(void)
{
int tmp, ret = 0;
if (ts78xx_fpga.supports.ts_rtc.present == 1) {
tmp = ts78xx_ts_rtc_load();
if (tmp)
printk(KERN_INFO "TS-78xx RTC not detected or enabled\n");
ret |= tmp;
}
return ret;
}
static int ts78xx_fpga_unload_devices(void)
{
int ret = 0;
if (ts78xx_fpga.supports.ts_rtc.present == 1)
ts78xx_ts_rtc_unload();
return ret;
}
static int ts78xx_fpga_load(void)
{
ts78xx_fpga.id = readl(TS78XX_FPGA_REGS_VIRT_BASE);
printk(KERN_INFO "TS-78xx FPGA: magic=0x%.6x, rev=0x%.2x\n",
(ts78xx_fpga.id >> 8) & 0xffffff,
ts78xx_fpga.id & 0xff);
ts78xx_fpga_supports();
if (ts78xx_fpga_load_devices()) {
ts78xx_fpga.state = -1;
return -EBUSY;
}
return 0;
}; };
/***************************************************************************** static int ts78xx_fpga_unload(void)
* print some information regarding the board
****************************************************************************/
static void __init ts78xx_print_board_id(void)
{ {
unsigned int board_info; unsigned int fpga_id;
board_info = readl(TS78XX_FPGA_REGS_SYSCON_ID); fpga_id = readl(TS78XX_FPGA_REGS_VIRT_BASE);
printk(KERN_INFO "TS-78xx Info: FPGA rev=%.2x, Board Magic=%.6x, ",
board_info & 0xff, /*
(board_info >> 8) & 0xffffff); * There does not seem to be a feasible way to block access to the GPIO
board_info = readl(TS78XX_FPGA_REGS_SYSCON_LCDI); * pins from userspace (/dev/mem). This if clause should hopefully warn
printk("JP1=%d, JP2=%d\n", * those foolish enough not to follow 'policy' :)
(board_info >> 30) & 0x1, *
(board_info >> 31) & 0x1); * UrJTAG SVN since r1381 can be used to reprogram the FPGA
*/
if (ts78xx_fpga.id != fpga_id) {
printk(KERN_ERR "TS-78xx FPGA: magic/rev mismatch\n"
"TS-78xx FPGA: was 0x%.6x/%.2x but now 0x%.6x/%.2x\n",
(ts78xx_fpga.id >> 8) & 0xffffff, ts78xx_fpga.id & 0xff,
(fpga_id >> 8) & 0xffffff, fpga_id & 0xff);
ts78xx_fpga.state = -1;
return -EBUSY;
}
if (ts78xx_fpga_unload_devices()) {
ts78xx_fpga.state = -1;
return -EBUSY;
}
return 0;
}; };
static ssize_t ts78xx_fpga_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
if (ts78xx_fpga.state < 0)
return sprintf(buf, "borked\n");
return sprintf(buf, "%s\n", (ts78xx_fpga.state) ? "online" : "offline");
}
static ssize_t ts78xx_fpga_store(struct kobject *kobj,
struct kobj_attribute *attr, const char *buf, size_t n)
{
int value, ret;
if (ts78xx_fpga.state < 0) {
printk(KERN_ERR "TS-78xx FPGA: borked, you must powercycle asap\n");
return -EBUSY;
}
if (strncmp(buf, "online", sizeof("online") - 1) == 0)
value = 1;
else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0)
value = 0;
else {
printk(KERN_ERR "ts78xx_fpga_store: Invalid value\n");
return -EINVAL;
}
if (ts78xx_fpga.state == value)
return n;
ret = (ts78xx_fpga.state == 0)
? ts78xx_fpga_load()
: ts78xx_fpga_unload();
if (!(ret < 0))
ts78xx_fpga.state = value;
return n;
}
static struct kobj_attribute ts78xx_fpga_attr =
__ATTR(ts78xx_fpga, 0644, ts78xx_fpga_show, ts78xx_fpga_store);
/***************************************************************************** /*****************************************************************************
* General Setup * General Setup
****************************************************************************/ ****************************************************************************/
...@@ -223,29 +318,28 @@ static struct orion5x_mpp_mode ts78xx_mpp_modes[] __initdata = { ...@@ -223,29 +318,28 @@ static struct orion5x_mpp_mode ts78xx_mpp_modes[] __initdata = {
{ 17, MPP_UART }, { 17, MPP_UART },
{ 18, MPP_UART }, { 18, MPP_UART },
{ 19, MPP_UART }, { 19, MPP_UART },
/*
* MPP[20] PCI Clock Out 1
* MPP[21] PCI Clock Out 0
* MPP[22] Unused
* MPP[23] Unused
* MPP[24] Unused
* MPP[25] Unused
*/
{ -1 }, { -1 },
}; };
static void __init ts78xx_init(void) static void __init ts78xx_init(void)
{ {
int ret;
/* /*
* Setup basic Orion functions. Need to be called early. * Setup basic Orion functions. Need to be called early.
*/ */
orion5x_init(); orion5x_init();
ts78xx_print_board_id();
orion5x_mpp_conf(ts78xx_mpp_modes); orion5x_mpp_conf(ts78xx_mpp_modes);
/*
* MPP[20] PCI Clock Out 1
* MPP[21] PCI Clock Out 0
* MPP[22] Unused
* MPP[23] Unused
* MPP[24] Unused
* MPP[25] Unused
*/
/* /*
* Configure peripherals. * Configure peripherals.
*/ */
...@@ -257,12 +351,12 @@ static void __init ts78xx_init(void) ...@@ -257,12 +351,12 @@ static void __init ts78xx_init(void)
orion5x_uart1_init(); orion5x_uart1_init();
orion5x_xor_init(); orion5x_xor_init();
orion5x_setup_dev_boot_win(TS78XX_NOR_BOOT_BASE, /* FPGA init */
TS78XX_NOR_BOOT_SIZE); ts78xx_fpga_devices_zero_init();
platform_device_register(&ts78xx_nor_boot_flash); ret = ts78xx_fpga_load();
ret = sysfs_create_file(power_kobj, &ts78xx_fpga_attr.attr);
if (!ts78xx_rtc_init()) if (ret)
printk(KERN_INFO "TS-78xx RTC not detected or enabled\n"); printk(KERN_ERR "sysfs_create_file failed: %d\n", ret);
} }
MACHINE_START(TS78XX, "Technologic Systems TS-78xx SBC") MACHINE_START(TS78XX, "Technologic Systems TS-78xx SBC")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册