diff options
Diffstat (limited to 'arch/mips/txx9/generic')
-rw-r--r-- | arch/mips/txx9/generic/7segled.c | 112 | ||||
-rw-r--r-- | arch/mips/txx9/generic/Makefile | 1 | ||||
-rw-r--r-- | arch/mips/txx9/generic/setup.c | 37 |
3 files changed, 146 insertions, 4 deletions
diff --git a/arch/mips/txx9/generic/7segled.c b/arch/mips/txx9/generic/7segled.c new file mode 100644 index 000000000000..727ab21b6618 --- /dev/null +++ b/arch/mips/txx9/generic/7segled.c | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | * 7 Segment LED routines | ||
3 | * Based on RBTX49xx patch from CELF patch archive. | ||
4 | * | ||
5 | * This file is subject to the terms and conditions of the GNU General Public | ||
6 | * License. See the file "COPYING" in the main directory of this archive | ||
7 | * for more details. | ||
8 | * | ||
9 | * (C) Copyright TOSHIBA CORPORATION 2005-2007 | ||
10 | * All Rights Reserved. | ||
11 | */ | ||
12 | #include <linux/sysdev.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/map_to_7segment.h> | ||
15 | #include <asm/txx9/generic.h> | ||
16 | |||
17 | static unsigned int tx_7segled_num; | ||
18 | static void (*tx_7segled_putc)(unsigned int pos, unsigned char val); | ||
19 | |||
20 | void __init txx9_7segled_init(unsigned int num, | ||
21 | void (*putc)(unsigned int pos, unsigned char val)) | ||
22 | { | ||
23 | tx_7segled_num = num; | ||
24 | tx_7segled_putc = putc; | ||
25 | } | ||
26 | |||
27 | static SEG7_CONVERSION_MAP(txx9_seg7map, MAP_ASCII7SEG_ALPHANUM_LC); | ||
28 | |||
29 | int txx9_7segled_putc(unsigned int pos, char c) | ||
30 | { | ||
31 | if (pos >= tx_7segled_num) | ||
32 | return -EINVAL; | ||
33 | c = map_to_seg7(&txx9_seg7map, c); | ||
34 | if (c < 0) | ||
35 | return c; | ||
36 | tx_7segled_putc(pos, c); | ||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | static ssize_t ascii_store(struct sys_device *dev, | ||
41 | struct sysdev_attribute *attr, | ||
42 | const char *buf, size_t size) | ||
43 | { | ||
44 | unsigned int ch = dev->id; | ||
45 | txx9_7segled_putc(ch, buf[0]); | ||
46 | return size; | ||
47 | } | ||
48 | |||
49 | static ssize_t raw_store(struct sys_device *dev, | ||
50 | struct sysdev_attribute *attr, | ||
51 | const char *buf, size_t size) | ||
52 | { | ||
53 | unsigned int ch = dev->id; | ||
54 | tx_7segled_putc(ch, buf[0]); | ||
55 | return size; | ||
56 | } | ||
57 | |||
58 | static SYSDEV_ATTR(ascii, 0200, NULL, ascii_store); | ||
59 | static SYSDEV_ATTR(raw, 0200, NULL, raw_store); | ||
60 | |||
61 | static ssize_t map_seg7_show(struct sysdev_class *class, char *buf) | ||
62 | { | ||
63 | memcpy(buf, &txx9_seg7map, sizeof(txx9_seg7map)); | ||
64 | return sizeof(txx9_seg7map); | ||
65 | } | ||
66 | |||
67 | static ssize_t map_seg7_store(struct sysdev_class *class, | ||
68 | const char *buf, size_t size) | ||
69 | { | ||
70 | if (size != sizeof(txx9_seg7map)) | ||
71 | return -EINVAL; | ||
72 | memcpy(&txx9_seg7map, buf, size); | ||
73 | return size; | ||
74 | } | ||
75 | |||
76 | static SYSDEV_CLASS_ATTR(map_seg7, 0600, map_seg7_show, map_seg7_store); | ||
77 | |||
78 | static struct sysdev_class tx_7segled_sysdev_class = { | ||
79 | .name = "7segled", | ||
80 | }; | ||
81 | |||
82 | static int __init tx_7segled_init_sysfs(void) | ||
83 | { | ||
84 | int error, i; | ||
85 | if (!tx_7segled_num) | ||
86 | return -ENODEV; | ||
87 | error = sysdev_class_register(&tx_7segled_sysdev_class); | ||
88 | if (error) | ||
89 | return error; | ||
90 | error = sysdev_class_create_file(&tx_7segled_sysdev_class, | ||
91 | &attr_map_seg7); | ||
92 | if (error) | ||
93 | return error; | ||
94 | for (i = 0; i < tx_7segled_num; i++) { | ||
95 | struct sys_device *dev; | ||
96 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | ||
97 | if (!dev) { | ||
98 | error = -ENODEV; | ||
99 | break; | ||
100 | } | ||
101 | dev->id = i; | ||
102 | dev->cls = &tx_7segled_sysdev_class; | ||
103 | error = sysdev_register(dev); | ||
104 | if (!error) { | ||
105 | sysdev_create_file(dev, &attr_ascii); | ||
106 | sysdev_create_file(dev, &attr_raw); | ||
107 | } | ||
108 | } | ||
109 | return error; | ||
110 | } | ||
111 | |||
112 | device_initcall(tx_7segled_init_sysfs); | ||
diff --git a/arch/mips/txx9/generic/Makefile b/arch/mips/txx9/generic/Makefile index 0030d23bef5b..f2579ce054a1 100644 --- a/arch/mips/txx9/generic/Makefile +++ b/arch/mips/txx9/generic/Makefile | |||
@@ -10,5 +10,6 @@ obj-$(CONFIG_SOC_TX4938) += mem_tx4927.o setup_tx4938.o irq_tx4938.o | |||
10 | obj-$(CONFIG_SOC_TX4939) += setup_tx4939.o irq_tx4939.o | 10 | obj-$(CONFIG_SOC_TX4939) += setup_tx4939.o irq_tx4939.o |
11 | obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o | 11 | obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o |
12 | obj-$(CONFIG_SPI) += spi_eeprom.o | 12 | obj-$(CONFIG_SPI) += spi_eeprom.o |
13 | obj-$(CONFIG_TXX9_7SEGLED) += 7segled.o | ||
13 | 14 | ||
14 | EXTRA_CFLAGS += -Werror | 15 | EXTRA_CFLAGS += -Werror |
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c index 5526375010f8..a13a08b8c9ec 100644 --- a/arch/mips/txx9/generic/setup.c +++ b/arch/mips/txx9/generic/setup.c | |||
@@ -156,11 +156,23 @@ static struct txx9_board_vec *__init find_board_byname(const char *name) | |||
156 | 156 | ||
157 | static void __init prom_init_cmdline(void) | 157 | static void __init prom_init_cmdline(void) |
158 | { | 158 | { |
159 | int argc = (int)fw_arg0; | 159 | int argc; |
160 | int *argv32 = (int *)fw_arg1; | 160 | int *argv32; |
161 | int i; /* Always ignore the "-c" at argv[0] */ | 161 | int i; /* Always ignore the "-c" at argv[0] */ |
162 | char builtin[CL_SIZE]; | 162 | char builtin[CL_SIZE]; |
163 | 163 | ||
164 | if (fw_arg0 >= CKSEG0 || fw_arg1 < CKSEG0) { | ||
165 | /* | ||
166 | * argc is not a valid number, or argv32 is not a valid | ||
167 | * pointer | ||
168 | */ | ||
169 | argc = 0; | ||
170 | argv32 = NULL; | ||
171 | } else { | ||
172 | argc = (int)fw_arg0; | ||
173 | argv32 = (int *)fw_arg1; | ||
174 | } | ||
175 | |||
164 | /* ignore all built-in args if any f/w args given */ | 176 | /* ignore all built-in args if any f/w args given */ |
165 | /* | 177 | /* |
166 | * But if built-in strings was started with '+', append them | 178 | * But if built-in strings was started with '+', append them |
@@ -414,10 +426,12 @@ char * __init prom_getcmdline(void) | |||
414 | 426 | ||
415 | const char *__init prom_getenv(const char *name) | 427 | const char *__init prom_getenv(const char *name) |
416 | { | 428 | { |
417 | const s32 *str = (const s32 *)fw_arg2; | 429 | const s32 *str; |
418 | 430 | ||
419 | if (!str) | 431 | if (fw_arg2 < CKSEG0) |
420 | return NULL; | 432 | return NULL; |
433 | |||
434 | str = (const s32 *)fw_arg2; | ||
421 | /* YAMON style ("name", "value" pairs) */ | 435 | /* YAMON style ("name", "value" pairs) */ |
422 | while (str[0] && str[1]) { | 436 | while (str[0] && str[1]) { |
423 | if (!strcmp((const char *)(unsigned long)str[0], name)) | 437 | if (!strcmp((const char *)(unsigned long)str[0], name)) |
@@ -622,6 +636,21 @@ unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none; | |||
622 | EXPORT_SYMBOL(__swizzle_addr_b); | 636 | EXPORT_SYMBOL(__swizzle_addr_b); |
623 | #endif | 637 | #endif |
624 | 638 | ||
639 | #ifdef NEEDS_TXX9_IOSWABW | ||
640 | static u16 ioswabw_default(volatile u16 *a, u16 x) | ||
641 | { | ||
642 | return le16_to_cpu(x); | ||
643 | } | ||
644 | static u16 __mem_ioswabw_default(volatile u16 *a, u16 x) | ||
645 | { | ||
646 | return x; | ||
647 | } | ||
648 | u16 (*ioswabw)(volatile u16 *a, u16 x) = ioswabw_default; | ||
649 | EXPORT_SYMBOL(ioswabw); | ||
650 | u16 (*__mem_ioswabw)(volatile u16 *a, u16 x) = __mem_ioswabw_default; | ||
651 | EXPORT_SYMBOL(__mem_ioswabw); | ||
652 | #endif | ||
653 | |||
625 | void __init txx9_physmap_flash_init(int no, unsigned long addr, | 654 | void __init txx9_physmap_flash_init(int no, unsigned long addr, |
626 | unsigned long size, | 655 | unsigned long size, |
627 | const struct physmap_flash_data *pdata) | 656 | const struct physmap_flash_data *pdata) |