gayle: reserve memory resources at once

* Reserve memory resources for all IDE ports at once by moving
  request_mem_region() out of 'for ()' loop and always defining
  GAYLE_IDEREG_SIZE to 0x2000.

* Keep memory resources even if no free IDE slots can be found
  (this driver is unloadable currently).

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 3b2a5c71
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#define GAYLE_BASE_4000 0xdd2020 /* A4000/A4000T */ #define GAYLE_BASE_4000 0xdd2020 /* A4000/A4000T */
#define GAYLE_BASE_1200 0xda0000 /* A1200/A600 and E-Matrix 530 */ #define GAYLE_BASE_1200 0xda0000 /* A1200/A600 and E-Matrix 530 */
#define GAYLE_IDEREG_SIZE 0x2000
/* /*
* Offsets from one of the above bases * Offsets from one of the above bases
*/ */
...@@ -56,13 +58,11 @@ ...@@ -56,13 +58,11 @@
#define GAYLE_NUM_HWIFS 1 #define GAYLE_NUM_HWIFS 1
#define GAYLE_NUM_PROBE_HWIFS GAYLE_NUM_HWIFS #define GAYLE_NUM_PROBE_HWIFS GAYLE_NUM_HWIFS
#define GAYLE_HAS_CONTROL_REG 1 #define GAYLE_HAS_CONTROL_REG 1
#define GAYLE_IDEREG_SIZE 0x2000
#else /* CONFIG_BLK_DEV_IDEDOUBLER */ #else /* CONFIG_BLK_DEV_IDEDOUBLER */
#define GAYLE_NUM_HWIFS 2 #define GAYLE_NUM_HWIFS 2
#define GAYLE_NUM_PROBE_HWIFS (ide_doubler ? GAYLE_NUM_HWIFS : \ #define GAYLE_NUM_PROBE_HWIFS (ide_doubler ? GAYLE_NUM_HWIFS : \
GAYLE_NUM_HWIFS-1) GAYLE_NUM_HWIFS-1)
#define GAYLE_HAS_CONTROL_REG (!ide_doubler) #define GAYLE_HAS_CONTROL_REG (!ide_doubler)
#define GAYLE_IDEREG_SIZE (ide_doubler ? 0x1000 : 0x2000)
static int ide_doubler; static int ide_doubler;
module_param_named(doubler, ide_doubler, bool, 0); module_param_named(doubler, ide_doubler, bool, 0);
...@@ -124,6 +124,9 @@ static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base, ...@@ -124,6 +124,9 @@ static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base,
static int __init gayle_init(void) static int __init gayle_init(void)
{ {
unsigned long phys_base, res_start, res_n;
unsigned long base, ctrlport, irqport;
ide_ack_intr_t *ack_intr;
int a4000, i; int a4000, i;
hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
...@@ -149,12 +152,6 @@ static int __init gayle_init(void) ...@@ -149,12 +152,6 @@ static int __init gayle_init(void)
#endif #endif
""); "");
for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) {
unsigned long base, ctrlport, irqport;
ide_ack_intr_t *ack_intr;
ide_hwif_t *hwif;
unsigned long phys_base, res_start, res_n;
if (a4000) { if (a4000) {
phys_base = GAYLE_BASE_4000; phys_base = GAYLE_BASE_4000;
irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_4000); irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_4000);
...@@ -168,15 +165,16 @@ static int __init gayle_init(void) ...@@ -168,15 +165,16 @@ static int __init gayle_init(void)
* FIXME: we now have selectable modes between mmio v/s iomio * FIXME: we now have selectable modes between mmio v/s iomio
*/ */
phys_base += i*GAYLE_NEXT_PORT;
res_start = ((unsigned long)phys_base) & ~(GAYLE_NEXT_PORT-1); res_start = ((unsigned long)phys_base) & ~(GAYLE_NEXT_PORT-1);
res_n = GAYLE_IDEREG_SIZE; res_n = GAYLE_IDEREG_SIZE;
if (!request_mem_region(res_start, res_n, "IDE")) if (!request_mem_region(res_start, res_n, "IDE"))
continue; return -EBUSY;
base = (unsigned long)ZTWO_VADDR(phys_base); for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) {
ide_hwif_t *hwif;
base = (unsigned long)ZTWO_VADDR(phys_base + i * GAYLE_NEXT_PORT);
ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0; ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0;
gayle_setup_ports(&hw[i], base, ctrlport, irqport, ack_intr); gayle_setup_ports(&hw[i], base, ctrlport, irqport, ack_intr);
...@@ -187,8 +185,7 @@ static int __init gayle_init(void) ...@@ -187,8 +185,7 @@ static int __init gayle_init(void)
hws[i] = &hw[i]; hws[i] = &hw[i];
idx[i] = hwif->index; idx[i] = hwif->index;
} else }
release_mem_region(res_start, res_n);
} }
ide_device_add(idx, NULL, hws); ide_device_add(idx, NULL, hws);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment