Skip to content

Commit 6d7b42a

Browse files
plagniojdedekind
authored andcommitted
mtd: fsmc_nand: pass the ale and cmd resource via resource
Do not use the platform_data to pass resource and be smart in the drivers. Just pass it via resource Switch to devm_request_and_ioremap at the sametime Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-By: Vipin Kumar <vipin.kumar@st.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
1 parent fc05d5a commit 6d7b42a

9 files changed

Lines changed: 49 additions & 66 deletions

File tree

‎Documentation/devicetree/bindings/mtd/fsmc-nand.txt‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
Required properties:
44
- compatible : "st,spear600-fsmc-nand"
55
- reg : Address range of the mtd chip
6-
- reg-names: Should contain the reg names "fsmc_regs" and "nand_data"
7-
- st,ale-off : Chip specific offset to ALE
8-
- st,cle-off : Chip specific offset to CLE
6+
- reg-names: Should contain the reg names "fsmc_regs", "nand_data", "nand_addr" and "nand_cmd"
97

108
Optional properties:
119
- bank-width : Width (in bytes) of the device. If not present, the width
@@ -19,10 +17,10 @@ Example:
1917
#address-cells = <1>;
2018
#size-cells = <1>;
2119
reg = <0xd1800000 0x1000 /* FSMC Register */
22-
0xd2000000 0x4000>; /* NAND Base */
23-
reg-names = "fsmc_regs", "nand_data";
24-
st,ale-off = <0x20000>;
25-
st,cle-off = <0x10000>;
20+
0xd2000000 0x0010 /* NAND Base DATA */
21+
0xd2020000 0x0010 /* NAND Base ADDR */
22+
0xd2010000 0x0010>; /* NAND Base CMD */
23+
reg-names = "fsmc_regs", "nand_data", "nand_addr", "nand_cmd";
2624

2725
bank-width = <1>;
2826
nand-skip-bbtscan;

‎arch/arm/boot/dts/spear13xx.dtsi‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@
104104
compatible = "st,spear600-fsmc-nand";
105105
#address-cells = <1>;
106106
#size-cells = <1>;
107-
reg = <0xb0000000 0x1000 /* FSMC Register */
108-
0xb0800000 0x0010>; /* NAND Base */
109-
reg-names = "fsmc_regs", "nand_data";
107+
reg = <0xb0000000 0x1000 /* FSMC Register*/
108+
0xb0800000 0x0010 /* NAND Base DATA */
109+
0xb0820000 0x0010 /* NAND Base ADDR */
110+
0xb0810000 0x0010>; /* NAND Base CMD */
111+
reg-names = "fsmc_regs", "nand_data", "nand_addr", "nand_cmd";
110112
interrupts = <0 20 0x4
111113
0 21 0x4
112114
0 22 0x4
113115
0 23 0x4>;
114-
st,ale-off = <0x20000>;
115-
st,cle-off = <0x10000>;
116116
status = "disabled";
117117
};
118118

‎arch/arm/boot/dts/spear300.dtsi‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
#address-cells = <1>;
3939
#size-cells = <1>;
4040
reg = <0x94000000 0x1000 /* FSMC Register */
41-
0x80000000 0x0010>; /* NAND Base */
42-
reg-names = "fsmc_regs", "nand_data";
43-
st,ale-off = <0x20000>;
44-
st,cle-off = <0x10000>;
41+
0x80000000 0x0010 /* NAND Base DATA */
42+
0x80020000 0x0010 /* NAND Base ADDR */
43+
0x80010000 0x0010>; /* NAND Base CMD */
44+
reg-names = "fsmc_regs", "nand_data", "nand_addr", "nand_cmd";
4545
status = "disabled";
4646
};
4747

‎arch/arm/boot/dts/spear310.dtsi‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
#address-cells = <1>;
3333
#size-cells = <1>;
3434
reg = <0x44000000 0x1000 /* FSMC Register */
35-
0x40000000 0x0010>; /* NAND Base */
36-
reg-names = "fsmc_regs", "nand_data";
37-
st,ale-off = <0x10000>;
38-
st,cle-off = <0x20000>;
35+
0x40000000 0x0010 /* NAND Base DATA */
36+
0x40020000 0x0010 /* NAND Base ADDR */
37+
0x40010000 0x0010>; /* NAND Base CMD */
38+
reg-names = "fsmc_regs", "nand_data", "nand_addr", "nand_cmd";
3939
status = "disabled";
4040
};
4141

‎arch/arm/boot/dts/spear320.dtsi‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
#address-cells = <1>;
3939
#size-cells = <1>;
4040
reg = <0x4c000000 0x1000 /* FSMC Register */
41-
0x50000000 0x0010>; /* NAND Base */
42-
reg-names = "fsmc_regs", "nand_data";
43-
st,ale-off = <0x20000>;
44-
st,cle-off = <0x10000>;
41+
0x50000000 0x0010 /* NAND Base DATA */
42+
0x50020000 0x0010 /* NAND Base ADDR */
43+
0x50010000 0x0010>; /* NAND Base CMD */
44+
reg-names = "fsmc_regs", "nand_data", "nand_addr", "nand_cmd";
4545
status = "disabled";
4646
};
4747

‎arch/arm/boot/dts/spear600.dtsi‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@
6767
#address-cells = <1>;
6868
#size-cells = <1>;
6969
reg = <0xd1800000 0x1000 /* FSMC Register */
70-
0xd2000000 0x4000>; /* NAND Base */
71-
reg-names = "fsmc_regs", "nand_data";
72-
st,ale-off = <0x20000>;
73-
st,cle-off = <0x10000>;
70+
0xd2000000 0x0010 /* NAND Base DATA */
71+
0xd2020000 0x0010 /* NAND Base ADDR */
72+
0xd2010000 0x0010>; /* NAND Base CMD */
73+
reg-names = "fsmc_regs", "nand_data", "nand_addr", "nand_cmd";
7474
status = "disabled";
7575
};
7676

‎arch/arm/mach-u300/core.c‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,18 @@ static struct resource rtc_resources[] = {
251251
* but these are not yet used by the driver.
252252
*/
253253
static struct resource fsmc_resources[] = {
254+
{
255+
.name = "nand_addr",
256+
.start = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_ALE,
257+
.end = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_ALE + SZ_16K - 1,
258+
.flags = IORESOURCE_MEM,
259+
},
260+
{
261+
.name = "nand_cmd",
262+
.start = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_CLE,
263+
.end = U300_NAND_CS0_PHYS_BASE + PLAT_NAND_CLE + SZ_16K - 1,
264+
.flags = IORESOURCE_MEM,
265+
},
254266
{
255267
.name = "nand_data",
256268
.start = U300_NAND_CS0_PHYS_BASE,
@@ -1496,8 +1508,6 @@ static struct fsmc_nand_platform_data nand_platform_data = {
14961508
.nr_partitions = ARRAY_SIZE(u300_partitions),
14971509
.options = NAND_SKIP_BBTSCAN,
14981510
.width = FSMC_NAND_BW8,
1499-
.ale_off = PLAT_NAND_ALE,
1500-
.cle_off = PLAT_NAND_CLE,
15011511
};
15021512

15031513
static struct platform_device nand_device = {

‎drivers/mtd/nand/fsmc_nand.c‎

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,6 @@ static int __devinit fsmc_nand_probe_config_dt(struct platform_device *pdev,
876876
return -EINVAL;
877877
}
878878
}
879-
of_property_read_u32(np, "st,ale-off", &pdata->ale_off);
880-
of_property_read_u32(np, "st,cle-off", &pdata->cle_off);
881879
if (of_get_property(np, "nand-skip-bbtscan", NULL))
882880
pdata->options = NAND_SKIP_BBTSCAN;
883881

@@ -935,41 +933,28 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
935933
if (!res)
936934
return -EINVAL;
937935

938-
if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res),
939-
pdev->name)) {
940-
dev_err(&pdev->dev, "Failed to get memory data resourse\n");
941-
return -ENOENT;
942-
}
943-
944-
host->data_pa = (dma_addr_t)res->start;
945-
host->data_va = devm_ioremap(&pdev->dev, res->start,
946-
resource_size(res));
936+
host->data_va = devm_request_and_ioremap(&pdev->dev, res);
947937
if (!host->data_va) {
948938
dev_err(&pdev->dev, "data ioremap failed\n");
949939
return -ENOMEM;
950940
}
941+
host->data_pa = (dma_addr_t)res->start;
951942

952-
if (!devm_request_mem_region(&pdev->dev, res->start + pdata->ale_off,
953-
resource_size(res), pdev->name)) {
954-
dev_err(&pdev->dev, "Failed to get memory ale resourse\n");
955-
return -ENOENT;
956-
}
943+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_addr");
944+
if (!res)
945+
return -EINVAL;
957946

958-
host->addr_va = devm_ioremap(&pdev->dev, res->start + pdata->ale_off,
959-
resource_size(res));
947+
host->addr_va = devm_request_and_ioremap(&pdev->dev, res);
960948
if (!host->addr_va) {
961949
dev_err(&pdev->dev, "ale ioremap failed\n");
962950
return -ENOMEM;
963951
}
964952

965-
if (!devm_request_mem_region(&pdev->dev, res->start + pdata->cle_off,
966-
resource_size(res), pdev->name)) {
967-
dev_err(&pdev->dev, "Failed to get memory cle resourse\n");
968-
return -ENOENT;
969-
}
953+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_cmd");
954+
if (!res)
955+
return -EINVAL;
970956

971-
host->cmd_va = devm_ioremap(&pdev->dev, res->start + pdata->cle_off,
972-
resource_size(res));
957+
host->cmd_va = devm_request_and_ioremap(&pdev->dev, res);
973958
if (!host->cmd_va) {
974959
dev_err(&pdev->dev, "ale ioremap failed\n");
975960
return -ENOMEM;
@@ -979,14 +964,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
979964
if (!res)
980965
return -EINVAL;
981966

982-
if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res),
983-
pdev->name)) {
984-
dev_err(&pdev->dev, "Failed to get memory regs resourse\n");
985-
return -ENOENT;
986-
}
987-
988-
host->regs_va = devm_ioremap(&pdev->dev, res->start,
989-
resource_size(res));
967+
host->regs_va = devm_request_and_ioremap(&pdev->dev, res);
990968
if (!host->regs_va) {
991969
dev_err(&pdev->dev, "regs ioremap failed\n");
992970
return -ENOMEM;

‎include/linux/mtd/fsmc.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ struct fsmc_nand_platform_data {
155155
unsigned int width;
156156
unsigned int bank;
157157

158-
/* CLE, ALE offsets */
159-
unsigned int cle_off;
160-
unsigned int ale_off;
161158
enum access_mode mode;
162159

163160
void (*select_bank)(uint32_t bank, uint32_t busw);

0 commit comments

Comments
 (0)