bcm63xx: add a fixup for ath9k devices
[openwrt.git] / target / linux / brcm63xx / patches-3.3 / 427-MTD-m25p80-allow-passing-pp_data.patch
1 From 087a67d5750a51f5b0851228b5b2518f3300f7d8 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Thu, 3 May 2012 12:17:54 +0200
4 Subject: [PATCH 65/79] MIPS: BCM63XX: store the flash type in global variable
5
6 ---
7  arch/mips/bcm63xx/dev-flash.c                      |   36 +++++++++++++-------
8  .../include/asm/mach-bcm63xx/bcm63xx_dev_flash.h   |    2 ++
9  2 files changed, 26 insertions(+), 12 deletions(-)
10
11 --- a/arch/mips/bcm63xx/dev-flash.c
12 +++ b/arch/mips/bcm63xx/dev-flash.c
13 @@ -24,6 +24,8 @@
14  #include <bcm63xx_regs.h>
15  #include <bcm63xx_io.h>
16  
17 +int bcm63xx_attached_flash = -1;
18 +
19  static struct mtd_partition mtd_partitions[] = {
20         {
21                 .name           = "cfe",
22 @@ -81,20 +83,23 @@ static int __init bcm63xx_detect_flash_t
23                 bcm63xx_spi_flash_info[0].max_speed_hz = 40000000;
24                 val = bcm_misc_readl(MISC_STRAPBUS_6328_REG);
25                 if (val & STRAPBUS_6328_BOOT_SEL_SERIAL)
26 -                       return BCM63XX_FLASH_TYPE_SERIAL;
27 +                       bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
28                 else
29 -                       return BCM63XX_FLASH_TYPE_NAND;
30 +                       bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
31 +               break;
32         case BCM6338_CPU_ID:
33         case BCM6345_CPU_ID:
34         case BCM6348_CPU_ID:
35                 /* no way to auto detect so assume parallel */
36 -               return BCM63XX_FLASH_TYPE_PARALLEL;
37 +               bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
38 +               break;
39         case BCM6358_CPU_ID:
40                 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
41                 if (val & STRAPBUS_6358_BOOT_SEL_PARALLEL)
42 -                       return BCM63XX_FLASH_TYPE_PARALLEL;
43 +                       bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
44                 else
45 -                       return BCM63XX_FLASH_TYPE_SERIAL;
46 +                       bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
47 +               break;
48         case BCM6368_CPU_ID:
49                 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
50                 if (val & STRAPBUS_6368_SPI_CLK_FAST)
51 @@ -102,25 +107,32 @@ static int __init bcm63xx_detect_flash_t
52  
53                 switch (val & STRAPBUS_6368_BOOT_SEL_MASK) {
54                 case STRAPBUS_6368_BOOT_SEL_NAND:
55 -                       return BCM63XX_FLASH_TYPE_NAND;
56 +                       bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_NAND;
57 +                       break;
58                 case STRAPBUS_6368_BOOT_SEL_SERIAL:
59 -                       return BCM63XX_FLASH_TYPE_SERIAL;
60 +                       bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_SERIAL;
61 +                       break;
62                 case STRAPBUS_6368_BOOT_SEL_PARALLEL:
63 -                       return BCM63XX_FLASH_TYPE_PARALLEL;
64 +                       bcm63xx_attached_flash = BCM63XX_FLASH_TYPE_PARALLEL;
65 +                       break;
66 +               default:
67 +                       return -EINVAL;
68                 }
69         default:
70                 return -EINVAL;
71         }
72 +
73 +       return 0;
74  }
75  
76  int __init bcm63xx_flash_register(void)
77  {
78 -       int flash_type;
79         u32 val;
80  
81 -       flash_type = bcm63xx_detect_flash_type();
82  
83 -       switch (flash_type) {
84 +       bcm63xx_detect_flash_type();
85 +
86 +       switch (bcm63xx_attached_flash) {
87         case BCM63XX_FLASH_TYPE_PARALLEL:
88                 /* read base address of boot chip select (0) */
89                 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
90 @@ -141,7 +153,7 @@ int __init bcm63xx_flash_register(void)
91                 return -ENODEV;
92         default:
93                 pr_err("flash detection failed for BCM%x: %d",
94 -                      bcm63xx_get_cpu_id(), flash_type);
95 +                      bcm63xx_get_cpu_id(), bcm63xx_attached_flash);
96                 return -ENODEV;
97         }
98  }
99 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
100 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
101 @@ -7,6 +7,8 @@ enum {
102         BCM63XX_FLASH_TYPE_NAND,
103  };
104  
105 +extern int bcm63xx_attached_flash;
106 +
107  int __init bcm63xx_flash_register(void);
108  
109  #endif /* __BCM63XX_FLASH_H */