diff options
author | Roger Quadros <rogerq@ti.com> | 2014-08-29 12:11:53 -0400 |
---|---|---|
committer | Roger Quadros <rogerq@ti.com> | 2014-10-30 11:21:46 -0400 |
commit | 4cf27d2ec716fddacd02169af9a26a43ea52875e (patch) | |
tree | 9c92e43a9629ce9393ab5f04559cb16eb79416de /arch/arm/mach-omap2 | |
parent | e378d22b9c27de4af4946e4e7928fef50f9a9ff7 (diff) |
ARM: OMAP2+: gpmc: Keep Chip Select disabled while configuring it
As per the OMAP reference manual [1], the Chip Select must be
disabled (i.e. CSVALID is 0) while configuring any of the
Chip select parameters.
[1] - 10.1.5.1 Chip-Select Base Address and Region Size Configuration
http://www.ti.com/lit/pdf/swpu177
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r-- | arch/arm/mach-omap2/gpmc.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 0ba95d3e74e5..437fb6f6df52 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c | |||
@@ -397,7 +397,7 @@ int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t) | |||
397 | return 0; | 397 | return 0; |
398 | } | 398 | } |
399 | 399 | ||
400 | static int gpmc_cs_enable_mem(int cs, u32 base, u32 size) | 400 | static int gpmc_cs_set_memconf(int cs, u32 base, u32 size) |
401 | { | 401 | { |
402 | u32 l; | 402 | u32 l; |
403 | u32 mask; | 403 | u32 mask; |
@@ -421,6 +421,15 @@ static int gpmc_cs_enable_mem(int cs, u32 base, u32 size) | |||
421 | return 0; | 421 | return 0; |
422 | } | 422 | } |
423 | 423 | ||
424 | static void gpmc_cs_enable_mem(int cs) | ||
425 | { | ||
426 | u32 l; | ||
427 | |||
428 | l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); | ||
429 | l |= GPMC_CONFIG7_CSVALID; | ||
430 | gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l); | ||
431 | } | ||
432 | |||
424 | static void gpmc_cs_disable_mem(int cs) | 433 | static void gpmc_cs_disable_mem(int cs) |
425 | { | 434 | { |
426 | u32 l; | 435 | u32 l; |
@@ -532,18 +541,18 @@ static int gpmc_cs_remap(int cs, u32 base) | |||
532 | gpmc_cs_get_memconf(cs, &old_base, &size); | 541 | gpmc_cs_get_memconf(cs, &old_base, &size); |
533 | if (base == old_base) | 542 | if (base == old_base) |
534 | return 0; | 543 | return 0; |
535 | gpmc_cs_disable_mem(cs); | 544 | |
536 | ret = gpmc_cs_delete_mem(cs); | 545 | ret = gpmc_cs_delete_mem(cs); |
537 | if (ret < 0) | 546 | if (ret < 0) |
538 | return ret; | 547 | return ret; |
548 | |||
539 | ret = gpmc_cs_insert_mem(cs, base, size); | 549 | ret = gpmc_cs_insert_mem(cs, base, size); |
540 | if (ret < 0) | 550 | if (ret < 0) |
541 | return ret; | 551 | return ret; |
542 | ret = gpmc_cs_enable_mem(cs, base, size); | ||
543 | if (ret < 0) | ||
544 | return ret; | ||
545 | 552 | ||
546 | return 0; | 553 | ret = gpmc_cs_set_memconf(cs, base, size); |
554 | |||
555 | return ret; | ||
547 | } | 556 | } |
548 | 557 | ||
549 | int gpmc_cs_request(int cs, unsigned long size, unsigned long *base) | 558 | int gpmc_cs_request(int cs, unsigned long size, unsigned long *base) |
@@ -572,12 +581,17 @@ int gpmc_cs_request(int cs, unsigned long size, unsigned long *base) | |||
572 | if (r < 0) | 581 | if (r < 0) |
573 | goto out; | 582 | goto out; |
574 | 583 | ||
575 | r = gpmc_cs_enable_mem(cs, res->start, resource_size(res)); | 584 | /* Disable CS while changing base address and size mask */ |
585 | gpmc_cs_disable_mem(cs); | ||
586 | |||
587 | r = gpmc_cs_set_memconf(cs, res->start, resource_size(res)); | ||
576 | if (r < 0) { | 588 | if (r < 0) { |
577 | release_resource(res); | 589 | release_resource(res); |
578 | goto out; | 590 | goto out; |
579 | } | 591 | } |
580 | 592 | ||
593 | /* Enable CS */ | ||
594 | gpmc_cs_enable_mem(cs); | ||
581 | *base = res->start; | 595 | *base = res->start; |
582 | gpmc_cs_set_reserved(cs, 1); | 596 | gpmc_cs_set_reserved(cs, 1); |
583 | out: | 597 | out: |
@@ -1539,6 +1553,9 @@ static int gpmc_probe_generic_child(struct platform_device *pdev, | |||
1539 | goto no_timings; | 1553 | goto no_timings; |
1540 | } | 1554 | } |
1541 | 1555 | ||
1556 | /* CS must be disabled while making changes to gpmc configuration */ | ||
1557 | gpmc_cs_disable_mem(cs); | ||
1558 | |||
1542 | /* | 1559 | /* |
1543 | * FIXME: gpmc_cs_request() will map the CS to an arbitary | 1560 | * FIXME: gpmc_cs_request() will map the CS to an arbitary |
1544 | * location in the gpmc address space. When booting with | 1561 | * location in the gpmc address space. When booting with |
@@ -1577,6 +1594,9 @@ static int gpmc_probe_generic_child(struct platform_device *pdev, | |||
1577 | val &= ~GPMC_CONFIG_LIMITEDADDRESS; | 1594 | val &= ~GPMC_CONFIG_LIMITEDADDRESS; |
1578 | gpmc_write_reg(GPMC_CONFIG, val); | 1595 | gpmc_write_reg(GPMC_CONFIG, val); |
1579 | 1596 | ||
1597 | /* Enable CS region */ | ||
1598 | gpmc_cs_enable_mem(cs); | ||
1599 | |||
1580 | no_timings: | 1600 | no_timings: |
1581 | if (of_platform_device_create(child, NULL, &pdev->dev)) | 1601 | if (of_platform_device_create(child, NULL, &pdev->dev)) |
1582 | return 0; | 1602 | return 0; |