diff options
| -rw-r--r-- | drivers/ide/palm_bk3710.c | 67 |
1 files changed, 18 insertions, 49 deletions
diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.c index d1513b4a457c..13a5449aabf6 100644 --- a/drivers/ide/palm_bk3710.c +++ b/drivers/ide/palm_bk3710.c | |||
| @@ -42,16 +42,9 @@ | |||
| 42 | #define BK3710_BMICP 0x00 | 42 | #define BK3710_BMICP 0x00 |
| 43 | #define BK3710_BMISP 0x02 | 43 | #define BK3710_BMISP 0x02 |
| 44 | #define BK3710_BMIDTP 0x04 | 44 | #define BK3710_BMIDTP 0x04 |
| 45 | #define BK3710_BMICS 0x08 | ||
| 46 | #define BK3710_BMISS 0x0A | ||
| 47 | #define BK3710_BMIDTS 0x0C | ||
| 48 | #define BK3710_IDETIMP 0x40 | 45 | #define BK3710_IDETIMP 0x40 |
| 49 | #define BK3710_IDETIMS 0x42 | ||
| 50 | #define BK3710_SIDETIM 0x44 | ||
| 51 | #define BK3710_SLEWCTL 0x45 | ||
| 52 | #define BK3710_IDESTATUS 0x47 | 46 | #define BK3710_IDESTATUS 0x47 |
| 53 | #define BK3710_UDMACTL 0x48 | 47 | #define BK3710_UDMACTL 0x48 |
| 54 | #define BK3710_UDMATIM 0x4A | ||
| 55 | #define BK3710_MISCCTL 0x50 | 48 | #define BK3710_MISCCTL 0x50 |
| 56 | #define BK3710_REGSTB 0x54 | 49 | #define BK3710_REGSTB 0x54 |
| 57 | #define BK3710_REGRCVR 0x58 | 50 | #define BK3710_REGRCVR 0x58 |
| @@ -63,7 +56,6 @@ | |||
| 63 | #define BK3710_UDMATRP 0x70 | 56 | #define BK3710_UDMATRP 0x70 |
| 64 | #define BK3710_UDMAENV 0x74 | 57 | #define BK3710_UDMAENV 0x74 |
| 65 | #define BK3710_IORDYTMP 0x78 | 58 | #define BK3710_IORDYTMP 0x78 |
| 66 | #define BK3710_IORDYTMS 0x7C | ||
| 67 | 59 | ||
| 68 | static unsigned ideclk_period; /* in nanoseconds */ | 60 | static unsigned ideclk_period; /* in nanoseconds */ |
| 69 | 61 | ||
| @@ -96,11 +88,6 @@ static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, | |||
| 96 | trp = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].rptime, | 88 | trp = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].rptime, |
| 97 | ideclk_period) - 1; | 89 | ideclk_period) - 1; |
| 98 | 90 | ||
| 99 | /* udmatim Register */ | ||
| 100 | val16 = readw(base + BK3710_UDMATIM) & (dev ? 0xFF0F : 0xFFF0); | ||
| 101 | val16 |= (mode << (dev ? 4 : 0)); | ||
| 102 | writew(val16, base + BK3710_UDMATIM); | ||
| 103 | |||
| 104 | /* udmastb Ultra DMA Access Strobe Width */ | 91 | /* udmastb Ultra DMA Access Strobe Width */ |
| 105 | val32 = readl(base + BK3710_UDMASTB) & (0xFF << (dev ? 0 : 8)); | 92 | val32 = readl(base + BK3710_UDMASTB) & (0xFF << (dev ? 0 : 8)); |
| 106 | val32 |= (t0 << (dev ? 8 : 0)); | 93 | val32 |= (t0 << (dev ? 8 : 0)); |
| @@ -161,10 +148,11 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, | |||
| 161 | u32 val32; | 148 | u32 val32; |
| 162 | struct ide_timing *t; | 149 | struct ide_timing *t; |
| 163 | 150 | ||
| 151 | t = ide_timing_find_mode(XFER_PIO_0 + mode); | ||
| 152 | |||
| 164 | /* PIO Data Setup */ | 153 | /* PIO Data Setup */ |
| 165 | t0 = DIV_ROUND_UP(cycletime, ideclk_period); | 154 | t0 = DIV_ROUND_UP(cycletime, ideclk_period); |
| 166 | t2 = DIV_ROUND_UP(ide_timing_find_mode(XFER_PIO_0 + mode)->active, | 155 | t2 = DIV_ROUND_UP(t->active, ideclk_period); |
| 167 | ideclk_period); | ||
| 168 | 156 | ||
| 169 | t2i = t0 - t2 - 1; | 157 | t2i = t0 - t2 - 1; |
| 170 | t2 -= 1; | 158 | t2 -= 1; |
| @@ -185,7 +173,6 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, | |||
| 185 | } | 173 | } |
| 186 | 174 | ||
| 187 | /* TASKFILE Setup */ | 175 | /* TASKFILE Setup */ |
| 188 | t = ide_timing_find_mode(XFER_PIO_0 + mode); | ||
| 189 | t0 = DIV_ROUND_UP(t->cyc8b, ideclk_period); | 176 | t0 = DIV_ROUND_UP(t->cyc8b, ideclk_period); |
| 190 | t2 = DIV_ROUND_UP(t->act8b, ideclk_period); | 177 | t2 = DIV_ROUND_UP(t->act8b, ideclk_period); |
| 191 | 178 | ||
| @@ -234,42 +221,23 @@ static void palm_bk3710_set_pio_mode(ide_drive_t *drive, u8 pio) | |||
| 234 | static void __devinit palm_bk3710_chipinit(void __iomem *base) | 221 | static void __devinit palm_bk3710_chipinit(void __iomem *base) |
| 235 | { | 222 | { |
| 236 | /* | 223 | /* |
| 237 | * enable the reset_en of ATA controller so that when ata signals | 224 | * REVISIT: the ATA reset signal needs to be managed through a |
| 238 | * are brought out, by writing into device config. at that | 225 | * GPIO, which means it should come from platform_data. Until |
| 239 | * time por_n signal should not be 'Z' and have a stable value. | 226 | * we get and use such information, we have to trust that things |
| 227 | * have been reset before we get here. | ||
| 240 | */ | 228 | */ |
| 241 | writel(0x0300, base + BK3710_MISCCTL); | ||
| 242 | |||
| 243 | /* wait for some time and deassert the reset of ATA Device. */ | ||
| 244 | mdelay(100); | ||
| 245 | |||
| 246 | /* Deassert the Reset */ | ||
| 247 | writel(0x0200, base + BK3710_MISCCTL); | ||
| 248 | 229 | ||
| 249 | /* | 230 | /* |
| 250 | * Program the IDETIMP Register Value based on the following assumptions | 231 | * Program the IDETIMP Register Value based on the following assumptions |
| 251 | * | 232 | * |
| 252 | * (ATA_IDETIMP_IDEEN , ENABLE ) | | 233 | * (ATA_IDETIMP_IDEEN , ENABLE ) | |
| 253 | * (ATA_IDETIMP_SLVTIMEN , DISABLE) | | ||
| 254 | * (ATA_IDETIMP_RDYSMPL , 70NS) | | ||
| 255 | * (ATA_IDETIMP_RDYRCVRY , 50NS) | | ||
| 256 | * (ATA_IDETIMP_DMAFTIM1 , PIOCOMP) | | ||
| 257 | * (ATA_IDETIMP_PREPOST1 , DISABLE) | | 234 | * (ATA_IDETIMP_PREPOST1 , DISABLE) | |
| 258 | * (ATA_IDETIMP_RDYSEN1 , DISABLE) | | ||
| 259 | * (ATA_IDETIMP_PIOFTIM1 , DISABLE) | | ||
| 260 | * (ATA_IDETIMP_DMAFTIM0 , PIOCOMP) | | ||
| 261 | * (ATA_IDETIMP_PREPOST0 , DISABLE) | | 235 | * (ATA_IDETIMP_PREPOST0 , DISABLE) | |
| 262 | * (ATA_IDETIMP_RDYSEN0 , DISABLE) | | 236 | * |
| 263 | * (ATA_IDETIMP_PIOFTIM0 , DISABLE) | 237 | * DM6446 silicon rev 2.1 and earlier have no observed net benefit |
| 264 | */ | 238 | * from enabling prefetch/postwrite. |
| 265 | writew(0xB388, base + BK3710_IDETIMP); | ||
| 266 | |||
| 267 | /* | ||
| 268 | * Configure SIDETIM Register | ||
| 269 | * (ATA_SIDETIM_RDYSMPS1 ,120NS ) | | ||
| 270 | * (ATA_SIDETIM_RDYRCYS1 ,120NS ) | ||
| 271 | */ | 239 | */ |
| 272 | writeb(0, base + BK3710_SIDETIM); | 240 | writew(BIT(15), base + BK3710_IDETIMP); |
| 273 | 241 | ||
| 274 | /* | 242 | /* |
| 275 | * UDMACTL Ultra-ATA DMA Control | 243 | * UDMACTL Ultra-ATA DMA Control |
| @@ -281,11 +249,11 @@ static void __devinit palm_bk3710_chipinit(void __iomem *base) | |||
| 281 | 249 | ||
| 282 | /* | 250 | /* |
| 283 | * MISCCTL Miscellaneous Conrol Register | 251 | * MISCCTL Miscellaneous Conrol Register |
| 284 | * (ATA_MISCCTL_RSTMODEP , 1) | | 252 | * (ATA_MISCCTL_HWNHLD1P , 1 cycle) |
| 285 | * (ATA_MISCCTL_RESETP , 0) | | 253 | * (ATA_MISCCTL_HWNHLD0P , 1 cycle) |
| 286 | * (ATA_MISCCTL_TIMORIDE , 1) | 254 | * (ATA_MISCCTL_TIMORIDE , 1) |
| 287 | */ | 255 | */ |
| 288 | writel(0x201, base + BK3710_MISCCTL); | 256 | writel(0x001, base + BK3710_MISCCTL); |
| 289 | 257 | ||
| 290 | /* | 258 | /* |
| 291 | * IORDYTMP IORDY Timer for Primary Register | 259 | * IORDYTMP IORDY Timer for Primary Register |
| @@ -355,10 +323,9 @@ static int __init palm_bk3710_probe(struct platform_device *pdev) | |||
| 355 | 323 | ||
| 356 | clk_enable(clk); | 324 | clk_enable(clk); |
| 357 | rate = clk_get_rate(clk); | 325 | rate = clk_get_rate(clk); |
| 358 | ideclk_period = 1000000000UL / rate; | ||
| 359 | 326 | ||
| 360 | /* Register the IDE interface with Linux ATA Interface */ | 327 | /* NOTE: round *down* to meet minimum timings; we count in clocks */ |
| 361 | memset(&hw, 0, sizeof(hw)); | 328 | ideclk_period = 1000000000UL / rate; |
| 362 | 329 | ||
| 363 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 330 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 364 | if (mem == NULL) { | 331 | if (mem == NULL) { |
| @@ -388,6 +355,7 @@ static int __init palm_bk3710_probe(struct platform_device *pdev) | |||
| 388 | /* Configure the Palm Chip controller */ | 355 | /* Configure the Palm Chip controller */ |
| 389 | palm_bk3710_chipinit(base); | 356 | palm_bk3710_chipinit(base); |
| 390 | 357 | ||
| 358 | memset(&hw, 0, sizeof(hw)); | ||
| 391 | for (i = 0; i < IDE_NR_PORTS - 2; i++) | 359 | for (i = 0; i < IDE_NR_PORTS - 2; i++) |
| 392 | hw.io_ports_array[i] = (unsigned long) | 360 | hw.io_ports_array[i] = (unsigned long) |
| 393 | (base + IDE_PALM_ATA_PRI_REG_OFFSET + i); | 361 | (base + IDE_PALM_ATA_PRI_REG_OFFSET + i); |
| @@ -400,6 +368,7 @@ static int __init palm_bk3710_probe(struct platform_device *pdev) | |||
| 400 | palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 : | 368 | palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 : |
| 401 | ATA_UDMA5; | 369 | ATA_UDMA5; |
| 402 | 370 | ||
| 371 | /* Register the IDE interface with Linux */ | ||
| 403 | rc = ide_host_add(&palm_bk3710_port_info, hws, NULL); | 372 | rc = ide_host_add(&palm_bk3710_port_info, hws, NULL); |
| 404 | if (rc) | 373 | if (rc) |
| 405 | goto out; | 374 | goto out; |
