aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/include/asm/txx9/generic.h1
-rw-r--r--arch/mips/include/asm/txx9/tx4938.h1
-rw-r--r--arch/mips/include/asm/txx9/tx4939.h1
-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
8 files changed, 101 insertions, 0 deletions
diff --git a/arch/mips/include/asm/txx9/generic.h b/arch/mips/include/asm/txx9/generic.h
index 8169477d1475..827dc22be2ea 100644
--- a/arch/mips/include/asm/txx9/generic.h
+++ b/arch/mips/include/asm/txx9/generic.h
@@ -95,5 +95,6 @@ void __init txx9_aclc_init(unsigned long baseaddr, int irq,
95 unsigned int dmac_id, 95 unsigned int dmac_id,
96 unsigned int dma_chan_out, 96 unsigned int dma_chan_out,
97 unsigned int dma_chan_in); 97 unsigned int dma_chan_in);
98void __init txx9_sramc_init(struct resource *r);
98 99
99#endif /* __ASM_TXX9_GENERIC_H */ 100#endif /* __ASM_TXX9_GENERIC_H */
diff --git a/arch/mips/include/asm/txx9/tx4938.h b/arch/mips/include/asm/txx9/tx4938.h
index 54e467410a02..8a178f186f7d 100644
--- a/arch/mips/include/asm/txx9/tx4938.h
+++ b/arch/mips/include/asm/txx9/tx4938.h
@@ -307,5 +307,6 @@ struct tx4938ide_platform_info {
307void tx4938_ata_init(unsigned int irq, unsigned int shift, int tune); 307void tx4938_ata_init(unsigned int irq, unsigned int shift, int tune);
308void tx4938_dmac_init(int memcpy_chan0, int memcpy_chan1); 308void tx4938_dmac_init(int memcpy_chan0, int memcpy_chan1);
309void tx4938_aclc_init(void); 309void tx4938_aclc_init(void);
310void tx4938_sramc_init(void);
310 311
311#endif 312#endif
diff --git a/arch/mips/include/asm/txx9/tx4939.h b/arch/mips/include/asm/txx9/tx4939.h
index f13b708de617..050364d50b79 100644
--- a/arch/mips/include/asm/txx9/tx4939.h
+++ b/arch/mips/include/asm/txx9/tx4939.h
@@ -546,5 +546,6 @@ void tx4939_ndfmc_init(unsigned int hold, unsigned int spw,
546 unsigned char ch_mask, unsigned char wide_mask); 546 unsigned char ch_mask, unsigned char wide_mask);
547void tx4939_dmac_init(int memcpy_chan0, int memcpy_chan1); 547void tx4939_dmac_init(int memcpy_chan0, int memcpy_chan1);
548void tx4939_aclc_init(void); 548void tx4939_aclc_init(void);
549void tx4939_sramc_init(void);
549 550
550#endif /* __ASM_TXX9_TX4939_H */ 551#endif /* __ASM_TXX9_TX4939_H */
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)