Skip to content

Commit 6997af7

Browse files
David WoodhouseDavid Woodhouse
authored andcommitted
Merge commit '371a00448f95adaa612cf1a0b31a11e7093bc706' of 'git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git'
We need the following 2 patches from the 'net-next' tree for the BCMA flash driver: 371a004 bcma: detect and register NAND flash device d57ef3a bcma: detect and register serial flash device and this is why we are merging the net-next tree (presumably persistent) up to commit '371a004'. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2 parents 1749c00 + 371a004 commit 6997af7

177 files changed

Lines changed: 4948 additions & 1751 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎drivers/bcma/Kconfig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ config BCMA_DRIVER_MIPS
4848

4949
config BCMA_SFLASH
5050
bool
51-
depends on BCMA_DRIVER_MIPS && BROKEN
51+
depends on BCMA_DRIVER_MIPS
5252
default y
5353

5454
config BCMA_NFLASH
5555
bool
56-
depends on BCMA_DRIVER_MIPS && BROKEN
56+
depends on BCMA_DRIVER_MIPS
5757
default y
5858

5959
config BCMA_DRIVER_GMAC_CMN

‎drivers/bcma/bcma_private.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc);
5454
#ifdef CONFIG_BCMA_SFLASH
5555
/* driver_chipcommon_sflash.c */
5656
int bcma_sflash_init(struct bcma_drv_cc *cc);
57+
extern struct platform_device bcma_sflash_dev;
5758
#else
5859
static inline int bcma_sflash_init(struct bcma_drv_cc *cc)
5960
{
@@ -65,6 +66,7 @@ static inline int bcma_sflash_init(struct bcma_drv_cc *cc)
6566
#ifdef CONFIG_BCMA_NFLASH
6667
/* driver_chipcommon_nflash.c */
6768
int bcma_nflash_init(struct bcma_drv_cc *cc);
69+
extern struct platform_device bcma_nflash_dev;
6870
#else
6971
static inline int bcma_nflash_init(struct bcma_drv_cc *cc)
7072
{

‎drivers/bcma/driver_chipcommon_nflash.c‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,37 @@
55
* Licensed under the GNU/GPL. See COPYING for details.
66
*/
77

8+
#include <linux/platform_device.h>
89
#include <linux/bcma/bcma.h>
9-
#include <linux/bcma/bcma_driver_chipcommon.h>
10-
#include <linux/delay.h>
1110

1211
#include "bcma_private.h"
1312

13+
struct platform_device bcma_nflash_dev = {
14+
.name = "bcma_nflash",
15+
.num_resources = 0,
16+
};
17+
1418
/* Initialize NAND flash access */
1519
int bcma_nflash_init(struct bcma_drv_cc *cc)
1620
{
17-
bcma_err(cc->core->bus, "NAND flash support is broken\n");
21+
struct bcma_bus *bus = cc->core->bus;
22+
23+
if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
24+
cc->core->id.rev != 0x38) {
25+
bcma_err(bus, "NAND flash on unsupported board!\n");
26+
return -ENOTSUPP;
27+
}
28+
29+
if (!(cc->capabilities & BCMA_CC_CAP_NFLASH)) {
30+
bcma_err(bus, "NAND flash not present according to ChipCommon\n");
31+
return -ENODEV;
32+
}
33+
34+
cc->nflash.present = true;
35+
36+
/* Prepare platform device, but don't register it yet. It's too early,
37+
* malloc (required by device_private_init) is not available yet. */
38+
bcma_nflash_dev.dev.platform_data = &cc->nflash;
39+
1840
return 0;
1941
}

‎drivers/bcma/driver_chipcommon_pmu.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable)
101101
bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
102102
}
103103

104-
void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
104+
static void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
105105
{
106106
struct bcma_bus *bus = cc->core->bus;
107107

@@ -257,7 +257,7 @@ static u32 bcma_pmu_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
257257
}
258258

259259
/* query bus clock frequency for PMU-enabled chipcommon */
260-
u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
260+
static u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
261261
{
262262
struct bcma_bus *bus = cc->core->bus;
263263

‎drivers/bcma/driver_chipcommon_sflash.c‎

Lines changed: 120 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,132 @@
55
* Licensed under the GNU/GPL. See COPYING for details.
66
*/
77

8+
#include <linux/platform_device.h>
89
#include <linux/bcma/bcma.h>
9-
#include <linux/bcma/bcma_driver_chipcommon.h>
10-
#include <linux/delay.h>
1110

1211
#include "bcma_private.h"
1312

13+
static struct resource bcma_sflash_resource = {
14+
.name = "bcma_sflash",
15+
.start = BCMA_SFLASH,
16+
.end = 0,
17+
.flags = IORESOURCE_MEM | IORESOURCE_READONLY,
18+
};
19+
20+
struct platform_device bcma_sflash_dev = {
21+
.name = "bcma_sflash",
22+
.resource = &bcma_sflash_resource,
23+
.num_resources = 1,
24+
};
25+
26+
struct bcma_sflash_tbl_e {
27+
char *name;
28+
u32 id;
29+
u32 blocksize;
30+
u16 numblocks;
31+
};
32+
33+
static struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
34+
{ "", 0x14, 0x10000, 32, },
35+
{ 0 },
36+
};
37+
38+
static struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
39+
{ 0 },
40+
};
41+
42+
static struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
43+
{ 0 },
44+
};
45+
46+
static void bcma_sflash_cmd(struct bcma_drv_cc *cc, u32 opcode)
47+
{
48+
int i;
49+
bcma_cc_write32(cc, BCMA_CC_FLASHCTL,
50+
BCMA_CC_FLASHCTL_START | opcode);
51+
for (i = 0; i < 1000; i++) {
52+
if (!(bcma_cc_read32(cc, BCMA_CC_FLASHCTL) &
53+
BCMA_CC_FLASHCTL_BUSY))
54+
return;
55+
cpu_relax();
56+
}
57+
bcma_err(cc->core->bus, "SFLASH control command failed (timeout)!\n");
58+
}
59+
1460
/* Initialize serial flash access */
1561
int bcma_sflash_init(struct bcma_drv_cc *cc)
1662
{
17-
bcma_err(cc->core->bus, "Serial flash support is broken\n");
63+
struct bcma_bus *bus = cc->core->bus;
64+
struct bcma_sflash *sflash = &cc->sflash;
65+
struct bcma_sflash_tbl_e *e;
66+
u32 id, id2;
67+
68+
switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
69+
case BCMA_CC_FLASHT_STSER:
70+
bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_DP);
71+
72+
bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 0);
73+
bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
74+
id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
75+
76+
bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 1);
77+
bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
78+
id2 = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
79+
80+
switch (id) {
81+
case 0xbf:
82+
for (e = bcma_sflash_sst_tbl; e->name; e++) {
83+
if (e->id == id2)
84+
break;
85+
}
86+
break;
87+
default:
88+
for (e = bcma_sflash_st_tbl; e->name; e++) {
89+
if (e->id == id)
90+
break;
91+
}
92+
break;
93+
}
94+
if (!e->name) {
95+
bcma_err(bus, "Unsupported ST serial flash (id: 0x%X, id2: 0x%X)\n", id, id2);
96+
return -ENOTSUPP;
97+
}
98+
99+
break;
100+
case BCMA_CC_FLASHT_ATSER:
101+
bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_AT_STATUS);
102+
id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA) & 0x3c;
103+
104+
for (e = bcma_sflash_at_tbl; e->name; e++) {
105+
if (e->id == id)
106+
break;
107+
}
108+
if (!e->name) {
109+
bcma_err(bus, "Unsupported Atmel serial flash (id: 0x%X)\n", id);
110+
return -ENOTSUPP;
111+
}
112+
113+
break;
114+
default:
115+
bcma_err(bus, "Unsupported flash type\n");
116+
return -ENOTSUPP;
117+
}
118+
119+
sflash->window = BCMA_SFLASH;
120+
sflash->blocksize = e->blocksize;
121+
sflash->numblocks = e->numblocks;
122+
sflash->size = sflash->blocksize * sflash->numblocks;
123+
sflash->present = true;
124+
125+
bcma_info(bus, "Found %s serial flash (size: %dKiB, blocksize: 0x%X, blocks: %d)\n",
126+
e->name, sflash->size / 1024, sflash->blocksize,
127+
sflash->numblocks);
128+
129+
/* Prepare platform device, but don't register it yet. It's too early,
130+
* malloc (required by device_private_init) is not available yet. */
131+
bcma_sflash_dev.resource[0].end = bcma_sflash_dev.resource[0].start +
132+
sflash->size;
133+
bcma_sflash_dev.dev.platform_data = sflash;
134+
18135
return 0;
19136
}

‎drivers/bcma/host_pci.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ static void bcma_host_pci_write32(struct bcma_device *core, u16 offset,
7777
}
7878

7979
#ifdef CONFIG_BCMA_BLOCKIO
80-
void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
81-
size_t count, u16 offset, u8 reg_width)
80+
static void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
81+
size_t count, u16 offset, u8 reg_width)
8282
{
8383
void __iomem *addr = core->bus->mmio + offset;
8484
if (core->bus->mapped_core != core)
@@ -100,8 +100,9 @@ void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
100100
}
101101
}
102102

103-
void bcma_host_pci_block_write(struct bcma_device *core, const void *buffer,
104-
size_t count, u16 offset, u8 reg_width)
103+
static void bcma_host_pci_block_write(struct bcma_device *core,
104+
const void *buffer, size_t count,
105+
u16 offset, u8 reg_width)
105106
{
106107
void __iomem *addr = core->bus->mmio + offset;
107108
if (core->bus->mapped_core != core)
@@ -139,7 +140,7 @@ static void bcma_host_pci_awrite32(struct bcma_device *core, u16 offset,
139140
iowrite32(value, core->bus->mmio + (1 * BCMA_CORE_SIZE) + offset);
140141
}
141142

142-
const struct bcma_host_ops bcma_host_pci_ops = {
143+
static const struct bcma_host_ops bcma_host_pci_ops = {
143144
.read8 = bcma_host_pci_read8,
144145
.read16 = bcma_host_pci_read16,
145146
.read32 = bcma_host_pci_read32,

‎drivers/bcma/host_soc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static void bcma_host_soc_awrite32(struct bcma_device *core, u16 offset,
143143
writel(value, core->io_wrap + offset);
144144
}
145145

146-
const struct bcma_host_ops bcma_host_soc_ops = {
146+
static const struct bcma_host_ops bcma_host_soc_ops = {
147147
.read8 = bcma_host_soc_read8,
148148
.read16 = bcma_host_soc_read16,
149149
.read32 = bcma_host_soc_read32,

‎drivers/bcma/main.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "bcma_private.h"
99
#include <linux/module.h>
10+
#include <linux/platform_device.h>
1011
#include <linux/bcma/bcma.h>
1112
#include <linux/slab.h>
1213

@@ -136,6 +137,22 @@ static int bcma_register_cores(struct bcma_bus *bus)
136137
dev_id++;
137138
}
138139

140+
#ifdef CONFIG_BCMA_SFLASH
141+
if (bus->drv_cc.sflash.present) {
142+
err = platform_device_register(&bcma_sflash_dev);
143+
if (err)
144+
bcma_err(bus, "Error registering serial flash\n");
145+
}
146+
#endif
147+
148+
#ifdef CONFIG_BCMA_NFLASH
149+
if (bus->drv_cc.nflash.present) {
150+
err = platform_device_register(&bcma_nflash_dev);
151+
if (err)
152+
bcma_err(bus, "Error registering NAND flash\n");
153+
}
154+
#endif
155+
139156
return 0;
140157
}
141158

‎drivers/bluetooth/bcm203x.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
177177
if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
178178
return -ENODEV;
179179

180-
data = kzalloc(sizeof(*data), GFP_KERNEL);
180+
data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL);
181181
if (!data) {
182182
BT_ERR("Can't allocate memory for data structure");
183183
return -ENOMEM;
@@ -189,14 +189,12 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
189189
data->urb = usb_alloc_urb(0, GFP_KERNEL);
190190
if (!data->urb) {
191191
BT_ERR("Can't allocate URB");
192-
kfree(data);
193192
return -ENOMEM;
194193
}
195194

196195
if (request_firmware(&firmware, "BCM2033-MD.hex", &udev->dev) < 0) {
197196
BT_ERR("Mini driver request failed");
198197
usb_free_urb(data->urb);
199-
kfree(data);
200198
return -EIO;
201199
}
202200

@@ -209,7 +207,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
209207
BT_ERR("Can't allocate memory for mini driver");
210208
release_firmware(firmware);
211209
usb_free_urb(data->urb);
212-
kfree(data);
213210
return -ENOMEM;
214211
}
215212

@@ -224,7 +221,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
224221
BT_ERR("Firmware request failed");
225222
usb_free_urb(data->urb);
226223
kfree(data->buffer);
227-
kfree(data);
228224
return -EIO;
229225
}
230226

@@ -236,7 +232,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
236232
release_firmware(firmware);
237233
usb_free_urb(data->urb);
238234
kfree(data->buffer);
239-
kfree(data);
240235
return -ENOMEM;
241236
}
242237

@@ -271,7 +266,6 @@ static void bcm203x_disconnect(struct usb_interface *intf)
271266
usb_free_urb(data->urb);
272267
kfree(data->fw_data);
273268
kfree(data->buffer);
274-
kfree(data);
275269
}
276270

277271
static struct usb_driver bcm203x_driver = {

0 commit comments

Comments
 (0)