From: Masahiro A. <m-...@aa...> - 2001-07-18 11:13:33
|
Second Patch - Direct CompactFlash Support for SH4 --- diff -ruN linux-cvs0718-mr/ChangeLog linux-cvs0718-mr-cf/ChangeLog --- linux-cvs0718-mr/ChangeLog Wed Jul 18 18:53:49 2001 +++ linux-cvs0718-mr-cf/ChangeLog Wed Jul 18 19:12:57 2001 @@ -1,5 +1,12 @@ 2001-07-18 Masahiro ABE <m-...@aa...> + * Documentation/Configure.help (CONFIG_CF_ENABLER): Support area 5 also. + (CONFIG_CF_AREA): Added. + * arch/sh/config.in : Added selection of CompactFlash area. + * arch/sh/kernel/cf-enabler.c (allocate_cf_area): Added to support + directly connected CompactFlash for SH4. + (cf_init_default): call allocate_cf_area if SH4. + * arch/sh/kernel/irq_maskreg.c : Add support for simple word-size IRQ mask register. * include/asm-sh/irq.h : Likewise. diff -ruN linux-cvs0718-mr/Documentation/Configure.help linux-cvs0718-mr-cf/Documentation/Configure.help --- linux-cvs0718-mr/Documentation/Configure.help Wed Jul 18 18:44:08 2001 +++ linux-cvs0718-mr-cf/Documentation/Configure.help Wed Jul 18 19:18:14 2001 @@ -16400,7 +16400,7 @@ Directly Connected Compact Flash support CONFIG_CF_ENABLER - If your board has "Directly Connected" Compact Flash at area 6, + If your board has "Directly Connected" CompactFlash at area 5 or 6, you may want to enable this option. Then, you can use CF as primary IDE drive (only tested for SanDisk). @@ -16444,6 +16444,14 @@ say Y or M (for module). If unsure, say N. + +CompactFlash Connection Area +CONFIG_CF_AREA5 + If your board has "Directly Connected" CompactFlash, You should + select the area where your CF is connected to. + + It can be either Area5 (Physical address 0x14000000) or Area6 + (0x18000000). Default selection is Area6. # # m68k-specific kernel options diff -ruN linux-cvs0718-mr/arch/sh/config.in linux-cvs0718-mr-cf/arch/sh/config.in --- linux-cvs0718-mr/arch/sh/config.in Wed Jul 18 18:43:55 2001 +++ linux-cvs0718-mr-cf/arch/sh/config.in Wed Jul 18 19:08:15 2001 @@ -130,6 +130,18 @@ bool 'Compact Flash Enabler support' CONFIG_CF_ENABLER fi +if [ "$CONFIG_CF_ENABLER" = "y" ]; then + choice 'Compact Flash Connection Area' \ + "Area5 CONFIG_CF_AREA5 \ + Area6 CONFIG_CF_AREA6" Area6 + if [ "$CONFIG_CF_AREA5" = "y" ]; then + define_hex CONFIG_CF_BASE_ADDR b4000000 + fi + if [ "$CONFIG_CF_AREA6" = "y" ]; then + define_hex CONFIG_CF_BASE_ADDR b8000000 + fi +fi + bool 'Hitachi HD64461 companion chip support' CONFIG_HD64461 if [ "$CONFIG_HD64461" = "y" ]; then int 'HD64461 IRQ' CONFIG_HD64461_IRQ 36 diff -ruN linux-cvs0718-mr/arch/sh/kernel/cf-enabler.c linux-cvs0718-mr-cf/arch/sh/kernel/cf-enabler.c --- linux-cvs0718-mr/arch/sh/kernel/cf-enabler.c Wed Jul 18 18:43:55 2001 +++ linux-cvs0718-mr-cf/arch/sh/kernel/cf-enabler.c Wed Jul 18 18:55:34 2001 @@ -14,7 +14,6 @@ #include <asm/io.h> #include <asm/irq.h> -#define CF_CIS_BASE 0xb8000000 /* * You can connect Compact Flash directly to the bus of SuperH. * This is the enabler for that. @@ -29,15 +28,60 @@ * 0xB8001000 : Common Memory * 0xBA000000 : I/O */ +#if defined(CONFIG_IDE) && defined(__SH4__) +/* SH4 can't access PCMCIA interface through P2 area. + * we must remap it with appropreate attribute bit of the page set. + * this part is based on Greg Banks' hd64465_ss.c implementation - Masahiro Abe */ +#include <linux/mm.h> +#include <linux/vmalloc.h> + +#if defined(CONFIG_CF_AREA6) +#define slot_no 0 +#else +#define slot_no 1 +#endif + +/* defined in mm/ioremap.c */ +extern void * p3_ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags); + +/* use this pointer to access to directly connected compact flash io area*/ +void *cf_io_base; + +static int __init allocate_cf_area(void) +{ + pgprot_t prot; + unsigned long paddrbase, psize; + + /* open I/O area window */ + paddrbase = virt_to_phys((void*)CONFIG_CF_BASE_ADDR); + psize = PAGE_SIZE; + prot = PAGE_KERNEL_PCC(slot_no, _PAGE_PCC_IO16); + cf_io_base = p3_ioremap(paddrbase, psize, prot.pgprot); + if (!cf_io_base) { + printk("allocate_cf_area : can't open CF I/O window!\n"); + return -ENOMEM; + } +/* printk("p3_ioremap(paddr=0x%08lx, psize=0x%08lx, prot=0x%08lx)=0x%08lx\n", + paddrbase, psize, prot.pgprot, cf_io_base);*/ + + /* XXX : do we need attribute and common-memory area also? */ + + return 0; +} +#endif static int __init cf_init_default(void) { -#ifdef CONFIG_IDE - /* Enable the card, and set the level interrupt */ - ctrl_outw(0x0042, CF_CIS_BASE+0x0200); +/* You must have enabled the card, and set the level interrupt + * before reaching this point. Possibly in boot loader. + */ +#if defined(CONFIG_IDE) && defined(__SH4__) + allocate_cf_area(); #endif +/* This should be done in each board's init_xxx_irq. make_imask_irq(14); disable_irq(14); +*/ return 0; } --- ================================= Masahiro ABE, A&D Co., Ltd. Japan |