aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/txx9
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2009-05-25 09:04:02 -0400
committerRalf Baechle <ralf@linux-mips.org>2009-06-17 06:06:27 -0400
commitc3b28ae260d99a5364a31210a36a3246bd9647f7 (patch)
treeb24ffef4b1352f09af2944eea78685a7e3d38686 /arch/mips/txx9
parent05f94eebd55ef69a354d3ea70179e40ea4c34de6 (diff)
MIPS: TXx9: Add SRAMC support
Add a sysdev to access SRAM in TXx9 SoCs via sysfs. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/txx9')
-rw-r--r--arch/mips/txx9/generic/setup.c84
-rw-r--r--arch/mips/txx9/generic/setup_tx4938.c6
-rw-r--r--arch/mips/txx9/generic/setup_tx4939.c6
-rw-r--r--arch/mips/txx9/rbtx4938/setup.c1
-rw-r--r--arch/mips/txx9/rbtx4939/setup.c1
5 files changed, 98 insertions, 0 deletions
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 7f9101257615..3b7d77d61ce0 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -24,6 +24,7 @@
24#include <linux/serial_core.h> 24#include <linux/serial_core.h>
25#include <linux/mtd/physmap.h> 25#include <linux/mtd/physmap.h>
26#include <linux/leds.h> 26#include <linux/leds.h>
27#include <linux/sysdev.h>
27#include <asm/bootinfo.h> 28#include <asm/bootinfo.h>
28#include <asm/time.h> 29#include <asm/time.h>
29#include <asm/reboot.h> 30#include <asm/reboot.h>
@@ -912,3 +913,86 @@ void __init txx9_aclc_init(unsigned long baseaddr, int irq,
912 platform_device_put(pdev); 913 platform_device_put(pdev);
913#endif 914#endif
914} 915}
916
917static struct sysdev_class txx9_sramc_sysdev_class;
918
919struct txx9_sramc_sysdev {
920 struct sys_device dev;
921 struct bin_attribute bindata_attr;
922 void __iomem *base;
923};
924
925static ssize_t txx9_sram_read(struct kobject *kobj,
926 struct bin_attribute *bin_attr,
927 char *buf, loff_t pos, size_t size)
928{
929 struct txx9_sramc_sysdev *dev = bin_attr->private;
930 size_t ramsize = bin_attr->size;
931
932 if (pos >= ramsize)
933 return 0;
934 if (pos + size > ramsize)
935 size = ramsize - pos;
936 memcpy_fromio(buf, dev->base + pos, size);
937 return size;
938}
939
940static ssize_t txx9_sram_write(struct kobject *kobj,
941 struct bin_attribute *bin_attr,
942 char *buf, loff_t pos, size_t size)
943{
944 struct txx9_sramc_sysdev *dev = bin_attr->private;
945 size_t ramsize = bin_attr->size;
946
947 if (pos >= ramsize)
948 return 0;
949 if (pos + size > ramsize)
950 size = ramsize - pos;
951 memcpy_toio(dev->base + pos, buf, size);
952 return size;
953}
954
955void __init txx9_sramc_init(struct resource *r)
956{
957 struct txx9_sramc_sysdev *dev;
958 size_t size;
959 int err;
960
961 if (!txx9_sramc_sysdev_class.name) {
962 txx9_sramc_sysdev_class.name = "txx9_sram";
963 err = sysdev_class_register(&txx9_sramc_sysdev_class);
964 if (err) {
965 txx9_sramc_sysdev_class.name = NULL;
966 return;
967 }
968 }
969 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
970 if (!dev)
971 return;
972 size = resource_size(r);
973 dev->base = ioremap(r->start, size);
974 if (!dev->base)
975 goto exit;
976 dev->dev.cls = &txx9_sramc_sysdev_class;
977 dev->bindata_attr.attr.name = "bindata";
978 dev->bindata_attr.attr.mode = S_IRUSR | S_IWUSR;
979 dev->bindata_attr.read = txx9_sram_read;
980 dev->bindata_attr.write = txx9_sram_write;
981 dev->bindata_attr.size = size;
982 dev->bindata_attr.private = dev;
983 err = sysdev_register(&dev->dev);
984 if (err)
985 goto exit;
986 err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr);
987 if (err) {
988 sysdev_unregister(&dev->dev);
989 goto exit;
990 }
991 return;
992exit:
993 if (dev) {
994 if (dev->base)
995 iounmap(dev->base);
996 kfree(dev);
997 }
998}
diff --git a/arch/mips/txx9/generic/setup_tx4938.c b/arch/mips/txx9/generic/setup_tx4938.c
index 4dfdb52e8665..eb2080110239 100644
--- a/arch/mips/txx9/generic/setup_tx4938.c
+++ b/arch/mips/txx9/generic/setup_tx4938.c
@@ -425,6 +425,12 @@ void __init tx4938_aclc_init(void)
425 1, 0, 1); 425 1, 0, 1);
426} 426}
427 427
428void __init tx4938_sramc_init(void)
429{
430 if (tx4938_sram_resource.start)
431 txx9_sramc_init(&tx4938_sram_resource);
432}
433
428static void __init tx4938_stop_unused_modules(void) 434static void __init tx4938_stop_unused_modules(void)
429{ 435{
430 __u64 pcfg, rst = 0, ckd = 0; 436 __u64 pcfg, rst = 0, ckd = 0;
diff --git a/arch/mips/txx9/generic/setup_tx4939.c b/arch/mips/txx9/generic/setup_tx4939.c
index 71396863f54e..df13a891fb4b 100644
--- a/arch/mips/txx9/generic/setup_tx4939.c
+++ b/arch/mips/txx9/generic/setup_tx4939.c
@@ -494,6 +494,12 @@ void __init tx4939_aclc_init(void)
494 TXX9_IRQ_BASE + TX4939_IR_ACLC, 1, 0, 1); 494 TXX9_IRQ_BASE + TX4939_IR_ACLC, 1, 0, 1);
495} 495}
496 496
497void __init tx4939_sramc_init(void)
498{
499 if (tx4939_sram_resource.start)
500 txx9_sramc_init(&tx4939_sram_resource);
501}
502
497static void __init tx4939_stop_unused_modules(void) 503static void __init tx4939_stop_unused_modules(void)
498{ 504{
499 __u64 pcfg, rst = 0, ckd = 0; 505 __u64 pcfg, rst = 0, ckd = 0;
diff --git a/arch/mips/txx9/rbtx4938/setup.c b/arch/mips/txx9/rbtx4938/setup.c
index 8da66e956ee6..d66509b14284 100644
--- a/arch/mips/txx9/rbtx4938/setup.c
+++ b/arch/mips/txx9/rbtx4938/setup.c
@@ -358,6 +358,7 @@ static void __init rbtx4938_device_init(void)
358 tx4938_dmac_init(0, 2); 358 tx4938_dmac_init(0, 2);
359 tx4938_aclc_init(); 359 tx4938_aclc_init();
360 platform_device_register_simple("txx9aclc-generic", -1, NULL, 0); 360 platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
361 tx4938_sramc_init();
361 txx9_iocled_init(RBTX4938_LED_ADDR - IO_BASE, -1, 8, 1, "green", NULL); 362 txx9_iocled_init(RBTX4938_LED_ADDR - IO_BASE, -1, 8, 1, "green", NULL);
362} 363}
363 364
diff --git a/arch/mips/txx9/rbtx4939/setup.c b/arch/mips/txx9/rbtx4939/setup.c
index d5ad5abb80da..b9196966447b 100644
--- a/arch/mips/txx9/rbtx4939/setup.c
+++ b/arch/mips/txx9/rbtx4939/setup.c
@@ -501,6 +501,7 @@ static void __init rbtx4939_device_init(void)
501 tx4939_dmac_init(0, 2); 501 tx4939_dmac_init(0, 2);
502 tx4939_aclc_init(); 502 tx4939_aclc_init();
503 platform_device_register_simple("txx9aclc-generic", -1, NULL, 0); 503 platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
504 tx4939_sramc_init();
504} 505}
505 506
506static void __init rbtx4939_setup(void) 507static void __init rbtx4939_setup(void)