2 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
3 * and RBTX49xx patch from CELF patch archive.
5 * 2003-2005 (c) MontaVista Software, Inc.
6 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/interrupt.h>
16 #include <linux/string.h>
17 #include <linux/export.h>
18 #include <linux/clk-provider.h>
19 #include <linux/clkdev.h>
20 #include <linux/err.h>
21 #include <linux/gpio/driver.h>
22 #include <linux/platform_device.h>
23 #include <linux/platform_data/txx9/ndfmc.h>
24 #include <linux/serial_core.h>
25 #include <linux/mtd/physmap.h>
26 #include <linux/leds.h>
27 #include <linux/device.h>
28 #include <linux/slab.h>
30 #include <linux/irq.h>
31 #include <asm/bootinfo.h>
34 #include <asm/reboot.h>
35 #include <asm/r4kcache.h>
36 #include <asm/setup.h>
37 #include <asm/txx9/generic.h>
38 #include <asm/txx9/pci.h>
39 #include <asm/txx9tmr.h>
40 #include <asm/txx9/dmac.h>
41 #ifdef CONFIG_CPU_TX49XX
42 #include <asm/txx9/tx4938.h>
45 /* EBUSC settings of TX4927, etc. */
46 struct resource txx9_ce_res
[8];
47 static char txx9_ce_res_name
[8][4]; /* "CEn" */
49 /* pcode, internal register */
50 unsigned int txx9_pcode
;
51 char txx9_pcode_str
[8];
52 static struct resource txx9_reg_res
= {
53 .name
= txx9_pcode_str
,
54 .flags
= IORESOURCE_MEM
,
57 txx9_reg_res_init(unsigned int pcode
, unsigned long base
, unsigned long size
)
61 for (i
= 0; i
< ARRAY_SIZE(txx9_ce_res
); i
++) {
62 sprintf(txx9_ce_res_name
[i
], "CE%d", i
);
63 txx9_ce_res
[i
].flags
= IORESOURCE_MEM
;
64 txx9_ce_res
[i
].name
= txx9_ce_res_name
[i
];
68 sprintf(txx9_pcode_str
, "TX%x", pcode
);
70 txx9_reg_res
.start
= base
& 0xfffffffffULL
;
71 txx9_reg_res
.end
= (base
& 0xfffffffffULL
) + (size
- 1);
72 request_resource(&iomem_resource
, &txx9_reg_res
);
77 unsigned int txx9_master_clock
;
78 unsigned int txx9_cpu_clock
;
79 unsigned int txx9_gbus_clock
;
81 int txx9_ccfg_toeon __initdata
= 1;
83 #define BOARD_VEC(board) extern struct txx9_board_vec board;
84 #include <asm/txx9/boards.h>
87 struct txx9_board_vec
*txx9_board_vec __initdata
;
88 static char txx9_system_type
[32];
90 static struct txx9_board_vec
*board_vecs
[] __initdata
= {
91 #define BOARD_VEC(board) &board,
92 #include <asm/txx9/boards.h>
96 static struct txx9_board_vec
*__init
find_board_byname(const char *name
)
100 /* search board_vecs table */
101 for (i
= 0; i
< ARRAY_SIZE(board_vecs
); i
++) {
102 if (strstr(board_vecs
[i
]->system
, name
))
103 return board_vecs
[i
];
108 static void __init
prom_init_cmdline(void)
112 int i
; /* Always ignore the "-c" at argv[0] */
114 if (fw_arg0
>= CKSEG0
|| fw_arg1
< CKSEG0
) {
116 * argc is not a valid number, or argv32 is not a valid
123 argv32
= (int *)fw_arg1
;
126 arcs_cmdline
[0] = '\0';
128 for (i
= 1; i
< argc
; i
++) {
129 char *str
= (char *)(long)argv32
[i
];
131 strcat(arcs_cmdline
, " ");
132 if (strchr(str
, ' ')) {
133 strcat(arcs_cmdline
, "\"");
134 strcat(arcs_cmdline
, str
);
135 strcat(arcs_cmdline
, "\"");
137 strcat(arcs_cmdline
, str
);
141 static int txx9_ic_disable __initdata
;
142 static int txx9_dc_disable __initdata
;
144 #if defined(CONFIG_CPU_TX49XX)
145 /* flush all cache on very early stage (before 4k_cache_init) */
146 static void __init
early_flush_dcache(void)
148 unsigned int conf
= read_c0_config();
149 unsigned int dc_size
= 1 << (12 + ((conf
& CONF_DC
) >> 6));
150 unsigned int linesz
= 32;
151 unsigned long addr
, end
;
153 end
= INDEX_BASE
+ dc_size
/ 4;
155 for (addr
= INDEX_BASE
; addr
< end
; addr
+= linesz
) {
156 cache_op(Index_Writeback_Inv_D
, addr
| 0);
157 cache_op(Index_Writeback_Inv_D
, addr
| 1);
158 cache_op(Index_Writeback_Inv_D
, addr
| 2);
159 cache_op(Index_Writeback_Inv_D
, addr
| 3);
163 static void __init
txx9_cache_fixup(void)
167 conf
= read_c0_config();
168 /* flush and disable */
169 if (txx9_ic_disable
) {
170 conf
|= TX49_CONF_IC
;
171 write_c0_config(conf
);
173 if (txx9_dc_disable
) {
174 early_flush_dcache();
175 conf
|= TX49_CONF_DC
;
176 write_c0_config(conf
);
180 conf
= read_c0_config();
181 if (!txx9_ic_disable
)
182 conf
&= ~TX49_CONF_IC
;
183 if (!txx9_dc_disable
)
184 conf
&= ~TX49_CONF_DC
;
185 write_c0_config(conf
);
187 if (conf
& TX49_CONF_IC
)
188 pr_info("TX49XX I-Cache disabled.\n");
189 if (conf
& TX49_CONF_DC
)
190 pr_info("TX49XX D-Cache disabled.\n");
193 static inline void txx9_cache_fixup(void)
198 static void __init
preprocess_cmdline(void)
200 static char cmdline
[COMMAND_LINE_SIZE
] __initdata
;
203 strcpy(cmdline
, arcs_cmdline
);
205 arcs_cmdline
[0] = '\0';
207 char *str
= strsep(&s
, " ");
208 if (strncmp(str
, "board=", 6) == 0) {
209 txx9_board_vec
= find_board_byname(str
+ 6);
211 } else if (strncmp(str
, "masterclk=", 10) == 0) {
213 if (kstrtouint(str
+ 10, 10, &val
) == 0)
214 txx9_master_clock
= val
;
216 } else if (strcmp(str
, "icdisable") == 0) {
219 } else if (strcmp(str
, "dcdisable") == 0) {
222 } else if (strcmp(str
, "toeoff") == 0) {
225 } else if (strcmp(str
, "toeon") == 0) {
230 strcat(arcs_cmdline
, " ");
231 strcat(arcs_cmdline
, str
);
237 static void __init
select_board(void)
241 /* first, determine by "board=" argument in preprocess_cmdline() */
244 /* next, determine by "board" envvar */
245 envstr
= prom_getenv("board");
247 txx9_board_vec
= find_board_byname(envstr
);
252 /* select "default" board */
253 #ifdef CONFIG_CPU_TX49XX
254 switch (TX4938_REV_PCODE()) {
255 #ifdef CONFIG_TOSHIBA_RBTX4927
257 txx9_board_vec
= &rbtx4927_vec
;
260 txx9_board_vec
= &rbtx4937_vec
;
267 void __init
prom_init(void)
270 preprocess_cmdline();
273 strcpy(txx9_system_type
, txx9_board_vec
->system
);
275 txx9_board_vec
->prom_init();
278 const char *get_system_type(void)
280 return txx9_system_type
;
283 const char *__init
prom_getenv(const char *name
)
287 if (fw_arg2
< CKSEG0
)
290 str
= (const s32
*)fw_arg2
;
291 /* YAMON style ("name", "value" pairs) */
292 while (str
[0] && str
[1]) {
293 if (!strcmp((const char *)(unsigned long)str
[0], name
))
294 return (const char *)(unsigned long)str
[1];
300 static void __noreturn
txx9_machine_halt(void)
303 clear_c0_status(ST0_IM
);
307 if (cpu_has_counter
) {
309 * Clear counter interrupt while it
310 * breaks WAIT instruction even if
319 /* Watchdog support */
320 void __init
txx9_wdt_init(unsigned long base
)
322 struct resource res
= {
324 .end
= base
+ 0x100 - 1,
325 .flags
= IORESOURCE_MEM
,
327 platform_device_register_simple("txx9wdt", -1, &res
, 1);
330 void txx9_wdt_now(unsigned long base
)
332 struct txx9_tmr_reg __iomem
*tmrptr
=
333 ioremap(base
, sizeof(struct txx9_tmr_reg
));
334 /* disable watch dog timer */
335 __raw_writel(TXx9_TMWTMR_WDIS
| TXx9_TMWTMR_TWC
, &tmrptr
->wtmr
);
336 __raw_writel(0, &tmrptr
->tcr
);
338 __raw_writel(TXx9_TMWTMR_TWIE
, &tmrptr
->wtmr
);
339 __raw_writel(1, &tmrptr
->cpra
); /* immediate */
340 __raw_writel(TXx9_TMTCR_TCE
| TXx9_TMTCR_CCDE
| TXx9_TMTCR_TMODE_WDOG
,
345 void __init
txx9_spi_init(int busid
, unsigned long base
, int irq
)
347 struct resource res
[] = {
350 .end
= base
+ 0x20 - 1,
351 .flags
= IORESOURCE_MEM
,
354 .flags
= IORESOURCE_IRQ
,
357 platform_device_register_simple("spi_txx9", busid
,
358 res
, ARRAY_SIZE(res
));
361 void __init
txx9_ethaddr_init(unsigned int id
, unsigned char *ethaddr
)
363 struct platform_device
*pdev
=
364 platform_device_alloc("tc35815-mac", id
);
366 platform_device_add_data(pdev
, ethaddr
, 6) ||
367 platform_device_add(pdev
))
368 platform_device_put(pdev
);
371 void __init
txx9_sio_init(unsigned long baseaddr
, int irq
,
372 unsigned int line
, unsigned int sclk
, int nocts
)
374 #ifdef CONFIG_SERIAL_TXX9
375 struct uart_port req
;
377 memset(&req
, 0, sizeof(req
));
379 req
.iotype
= UPIO_MEM
;
380 req
.membase
= ioremap(baseaddr
, 0x24);
381 req
.mapbase
= baseaddr
;
384 req
.flags
|= UPF_BUGGY_UART
/*HAVE_CTS_LINE*/;
386 req
.flags
|= UPF_MAGIC_MULTIPLIER
/*USE_SCLK*/;
389 req
.uartclk
= TXX9_IMCLK
;
390 early_serial_txx9_setup(&req
);
391 #endif /* CONFIG_SERIAL_TXX9 */
394 #ifdef CONFIG_EARLY_PRINTK
395 static void null_prom_putchar(char c
)
398 void (*txx9_prom_putchar
)(char c
) = null_prom_putchar
;
400 void prom_putchar(char c
)
402 txx9_prom_putchar(c
);
405 static void __iomem
*early_txx9_sio_port
;
407 static void early_txx9_sio_putchar(char c
)
409 #define TXX9_SICISR 0x0c
410 #define TXX9_SITFIFO 0x1c
411 #define TXX9_SICISR_TXALS 0x00000002
412 while (!(__raw_readl(early_txx9_sio_port
+ TXX9_SICISR
) &
415 __raw_writel(c
, early_txx9_sio_port
+ TXX9_SITFIFO
);
418 void __init
txx9_sio_putchar_init(unsigned long baseaddr
)
420 early_txx9_sio_port
= ioremap(baseaddr
, 0x24);
421 txx9_prom_putchar
= early_txx9_sio_putchar
;
423 #endif /* CONFIG_EARLY_PRINTK */
426 void __init
plat_mem_setup(void)
428 ioport_resource
.start
= 0;
429 ioport_resource
.end
= ~0UL; /* no limit */
430 iomem_resource
.start
= 0;
431 iomem_resource
.end
= ~0UL; /* no limit */
433 /* fallback restart/halt routines */
434 _machine_restart
= (void (*)(char *))txx9_machine_halt
;
435 _machine_halt
= txx9_machine_halt
;
436 pm_power_off
= txx9_machine_halt
;
439 pcibios_plat_setup
= txx9_pcibios_setup
;
441 txx9_board_vec
->mem_setup();
444 void __init
arch_init_irq(void)
446 txx9_board_vec
->irq_setup();
449 void __init
plat_time_init(void)
451 #ifdef CONFIG_CPU_TX49XX
452 mips_hpt_frequency
= txx9_cpu_clock
/ 2;
454 txx9_board_vec
->time_init();
457 static void txx9_clk_init(void)
462 hw
= clk_hw_register_fixed_rate(NULL
, "gbus", NULL
, 0, txx9_gbus_clock
);
468 hw
= clk_hw_register_fixed_factor(NULL
, "imbus", "gbus", 0, 1, 2);
469 error
= clk_hw_register_clkdev(hw
, "imbus_clk", NULL
);
473 #ifdef CONFIG_CPU_TX49XX
474 if (TX4938_REV_PCODE() == 0x4938) {
475 hw
= clk_hw_register_fixed_factor(NULL
, "spi", "gbus", 0, 1, 4);
476 error
= clk_hw_register_clkdev(hw
, "spi-baseclk", NULL
);
485 pr_err("Failed to register clocks: %d\n", error
);
488 static int __init
_txx9_arch_init(void)
492 if (txx9_board_vec
->arch_init
)
493 txx9_board_vec
->arch_init();
496 arch_initcall(_txx9_arch_init
);
498 static int __init
_txx9_device_init(void)
500 if (txx9_board_vec
->device_init
)
501 txx9_board_vec
->device_init();
504 device_initcall(_txx9_device_init
);
506 int (*txx9_irq_dispatch
)(int pending
);
507 asmlinkage
void plat_irq_dispatch(void)
509 int pending
= read_c0_status() & read_c0_cause() & ST0_IM
;
510 int irq
= txx9_irq_dispatch(pending
);
512 if (likely(irq
>= 0))
515 spurious_interrupt();
518 /* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
519 #ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
520 static unsigned long __swizzle_addr_none(unsigned long port
)
524 unsigned long (*__swizzle_addr_b
)(unsigned long port
) = __swizzle_addr_none
;
525 EXPORT_SYMBOL(__swizzle_addr_b
);
528 void __init
txx9_physmap_flash_init(int no
, unsigned long addr
,
530 const struct physmap_flash_data
*pdata
)
532 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
533 struct resource res
= {
535 .end
= addr
+ size
- 1,
536 .flags
= IORESOURCE_MEM
,
538 struct platform_device
*pdev
;
539 static struct mtd_partition parts
[2];
540 struct physmap_flash_data pdata_part
;
542 /* If this area contained boot area, make separate partition */
543 if (pdata
->nr_parts
== 0 && !pdata
->parts
&&
544 addr
< 0x1fc00000 && addr
+ size
> 0x1fc00000 &&
546 parts
[0].name
= "boot";
547 parts
[0].offset
= 0x1fc00000 - addr
;
548 parts
[0].size
= addr
+ size
- 0x1fc00000;
549 parts
[1].name
= "user";
551 parts
[1].size
= 0x1fc00000 - addr
;
553 pdata_part
.nr_parts
= ARRAY_SIZE(parts
);
554 pdata_part
.parts
= parts
;
558 pdev
= platform_device_alloc("physmap-flash", no
);
560 platform_device_add_resources(pdev
, &res
, 1) ||
561 platform_device_add_data(pdev
, pdata
, sizeof(*pdata
)) ||
562 platform_device_add(pdev
))
563 platform_device_put(pdev
);
567 void __init
txx9_ndfmc_init(unsigned long baseaddr
,
568 const struct txx9ndfmc_platform_data
*pdata
)
570 #if IS_ENABLED(CONFIG_MTD_NAND_TXX9NDFMC)
571 struct resource res
= {
573 .end
= baseaddr
+ 0x1000 - 1,
574 .flags
= IORESOURCE_MEM
,
576 struct platform_device
*pdev
= platform_device_alloc("txx9ndfmc", -1);
579 platform_device_add_resources(pdev
, &res
, 1) ||
580 platform_device_add_data(pdev
, pdata
, sizeof(*pdata
)) ||
581 platform_device_add(pdev
))
582 platform_device_put(pdev
);
586 #if IS_ENABLED(CONFIG_LEDS_GPIO)
587 static DEFINE_SPINLOCK(txx9_iocled_lock
);
589 #define TXX9_IOCLED_MAXLEDS 8
591 struct txx9_iocled_data
{
592 struct gpio_chip chip
;
594 void __iomem
*mmioaddr
;
595 struct gpio_led_platform_data pdata
;
596 struct gpio_led leds
[TXX9_IOCLED_MAXLEDS
];
597 char names
[TXX9_IOCLED_MAXLEDS
][32];
600 static int txx9_iocled_get(struct gpio_chip
*chip
, unsigned int offset
)
602 struct txx9_iocled_data
*data
= gpiochip_get_data(chip
);
603 return !!(data
->cur_val
& (1 << offset
));
606 static void txx9_iocled_set(struct gpio_chip
*chip
, unsigned int offset
,
609 struct txx9_iocled_data
*data
= gpiochip_get_data(chip
);
611 spin_lock_irqsave(&txx9_iocled_lock
, flags
);
613 data
->cur_val
|= 1 << offset
;
615 data
->cur_val
&= ~(1 << offset
);
616 writeb(data
->cur_val
, data
->mmioaddr
);
618 spin_unlock_irqrestore(&txx9_iocled_lock
, flags
);
621 static int txx9_iocled_dir_in(struct gpio_chip
*chip
, unsigned int offset
)
626 static int txx9_iocled_dir_out(struct gpio_chip
*chip
, unsigned int offset
,
629 txx9_iocled_set(chip
, offset
, value
);
633 void __init
txx9_iocled_init(unsigned long baseaddr
,
634 int basenum
, unsigned int num
, int lowactive
,
635 const char *color
, char **deftriggers
)
637 struct txx9_iocled_data
*iocled
;
638 struct platform_device
*pdev
;
640 static char *default_triggers
[] __initdata
= {
648 deftriggers
= default_triggers
;
649 iocled
= kzalloc(sizeof(*iocled
), GFP_KERNEL
);
652 iocled
->mmioaddr
= ioremap(baseaddr
, 1);
653 if (!iocled
->mmioaddr
)
655 iocled
->chip
.get
= txx9_iocled_get
;
656 iocled
->chip
.set
= txx9_iocled_set
;
657 iocled
->chip
.direction_input
= txx9_iocled_dir_in
;
658 iocled
->chip
.direction_output
= txx9_iocled_dir_out
;
659 iocled
->chip
.label
= "iocled";
660 iocled
->chip
.base
= basenum
;
661 iocled
->chip
.ngpio
= num
;
662 if (gpiochip_add_data(&iocled
->chip
, iocled
))
665 basenum
= iocled
->chip
.base
;
667 pdev
= platform_device_alloc("leds-gpio", basenum
);
670 iocled
->pdata
.num_leds
= num
;
671 iocled
->pdata
.leds
= iocled
->leds
;
672 for (i
= 0; i
< num
; i
++) {
673 struct gpio_led
*led
= &iocled
->leds
[i
];
674 snprintf(iocled
->names
[i
], sizeof(iocled
->names
[i
]),
675 "iocled:%s:%u", color
, i
);
676 led
->name
= iocled
->names
[i
];
677 led
->gpio
= basenum
+ i
;
678 led
->active_low
= lowactive
;
679 if (deftriggers
&& *deftriggers
)
680 led
->default_trigger
= *deftriggers
++;
682 pdev
->dev
.platform_data
= &iocled
->pdata
;
683 if (platform_device_add(pdev
))
688 platform_device_put(pdev
);
690 gpiochip_remove(&iocled
->chip
);
692 iounmap(iocled
->mmioaddr
);
696 #else /* CONFIG_LEDS_GPIO */
697 void __init
txx9_iocled_init(unsigned long baseaddr
,
698 int basenum
, unsigned int num
, int lowactive
,
699 const char *color
, char **deftriggers
)
702 #endif /* CONFIG_LEDS_GPIO */
704 void __init
txx9_dmac_init(int id
, unsigned long baseaddr
, int irq
,
705 const struct txx9dmac_platform_data
*pdata
)
707 #if IS_ENABLED(CONFIG_TXX9_DMAC)
708 struct resource res
[] = {
711 .end
= baseaddr
+ 0x800 - 1,
712 .flags
= IORESOURCE_MEM
,
713 #ifndef CONFIG_MACH_TX49XX
716 .flags
= IORESOURCE_IRQ
,
720 #ifdef CONFIG_MACH_TX49XX
721 struct resource chan_res
[] = {
723 .flags
= IORESOURCE_IRQ
,
727 struct platform_device
*pdev
= platform_device_alloc("txx9dmac", id
);
728 struct txx9dmac_chan_platform_data cpdata
;
732 platform_device_add_resources(pdev
, res
, ARRAY_SIZE(res
)) ||
733 platform_device_add_data(pdev
, pdata
, sizeof(*pdata
)) ||
734 platform_device_add(pdev
)) {
735 platform_device_put(pdev
);
738 memset(&cpdata
, 0, sizeof(cpdata
));
739 cpdata
.dmac_dev
= pdev
;
740 for (i
= 0; i
< TXX9_DMA_MAX_NR_CHANNELS
; i
++) {
741 #ifdef CONFIG_MACH_TX49XX
742 chan_res
[0].start
= irq
+ i
;
744 pdev
= platform_device_alloc("txx9dmac-chan",
745 id
* TXX9_DMA_MAX_NR_CHANNELS
+ i
);
747 #ifdef CONFIG_MACH_TX49XX
748 platform_device_add_resources(pdev
, chan_res
,
749 ARRAY_SIZE(chan_res
)) ||
751 platform_device_add_data(pdev
, &cpdata
, sizeof(cpdata
)) ||
752 platform_device_add(pdev
))
753 platform_device_put(pdev
);
758 void __init
txx9_aclc_init(unsigned long baseaddr
, int irq
,
759 unsigned int dmac_id
,
760 unsigned int dma_chan_out
,
761 unsigned int dma_chan_in
)
765 static const struct bus_type txx9_sramc_subsys
= {
767 .dev_name
= "txx9_sram",
770 struct txx9_sramc_dev
{
772 struct bin_attribute bindata_attr
;
776 static ssize_t
txx9_sram_read(struct file
*filp
, struct kobject
*kobj
,
777 struct bin_attribute
*bin_attr
,
778 char *buf
, loff_t pos
, size_t size
)
780 struct txx9_sramc_dev
*dev
= bin_attr
->private;
781 size_t ramsize
= bin_attr
->size
;
785 if (pos
+ size
> ramsize
)
786 size
= ramsize
- pos
;
787 memcpy_fromio(buf
, dev
->base
+ pos
, size
);
791 static ssize_t
txx9_sram_write(struct file
*filp
, struct kobject
*kobj
,
792 struct bin_attribute
*bin_attr
,
793 char *buf
, loff_t pos
, size_t size
)
795 struct txx9_sramc_dev
*dev
= bin_attr
->private;
796 size_t ramsize
= bin_attr
->size
;
800 if (pos
+ size
> ramsize
)
801 size
= ramsize
- pos
;
802 memcpy_toio(dev
->base
+ pos
, buf
, size
);
806 static void txx9_device_release(struct device
*dev
)
808 struct txx9_sramc_dev
*tdev
;
810 tdev
= container_of(dev
, struct txx9_sramc_dev
, dev
);
814 void __init
txx9_sramc_init(struct resource
*r
)
816 struct txx9_sramc_dev
*dev
;
820 err
= subsys_system_register(&txx9_sramc_subsys
, NULL
);
823 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
826 size
= resource_size(r
);
827 dev
->base
= ioremap(r
->start
, size
);
832 dev
->dev
.release
= &txx9_device_release
;
833 dev
->dev
.bus
= &txx9_sramc_subsys
;
834 sysfs_bin_attr_init(&dev
->bindata_attr
);
835 dev
->bindata_attr
.attr
.name
= "bindata";
836 dev
->bindata_attr
.attr
.mode
= S_IRUSR
| S_IWUSR
;
837 dev
->bindata_attr
.read
= txx9_sram_read
;
838 dev
->bindata_attr
.write
= txx9_sram_write
;
839 dev
->bindata_attr
.size
= size
;
840 dev
->bindata_attr
.private = dev
;
841 err
= device_register(&dev
->dev
);
844 err
= sysfs_create_bin_file(&dev
->dev
.kobj
, &dev
->bindata_attr
);
847 device_unregister(&dev
->dev
);
852 put_device(&dev
->dev
);