Skip to content

Commit b6fe8bc

Browse files
Sergei Shtylyovr-vignesh
authored andcommitted
mtd: hyperbus: move direct mapping setup to AM654 HBMC driver
The Hyperbus core expects that HyperFlash is always directly mapped for both read and write, but in reality this may not always be the case, e.g. Renesas RPC-IF has read only direct mapping. Move the code setting up the direct mapping from the Hyperbus core to thh TI AM554 HBMC driver. Signed-off-by: Sergei Shtylyov <[email protected]> Signed-off-by: Vignesh Raghavendra <[email protected]>
1 parent cb6176e commit b6fe8bc

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

drivers/mtd/hyperbus/hbmc-am654.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/mtd/mtd.h>
1212
#include <linux/mux/consumer.h>
1313
#include <linux/of.h>
14+
#include <linux/of_address.h>
1415
#include <linux/platform_device.h>
1516
#include <linux/pm_runtime.h>
1617
#include <linux/types.h>
@@ -57,8 +58,10 @@ static const struct hyperbus_ops am654_hbmc_ops = {
5758

5859
static int am654_hbmc_probe(struct platform_device *pdev)
5960
{
61+
struct device_node *np = pdev->dev.of_node;
6062
struct device *dev = &pdev->dev;
6163
struct am654_hbmc_priv *priv;
64+
struct resource res;
6265
int ret;
6366

6467
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -67,6 +70,10 @@ static int am654_hbmc_probe(struct platform_device *pdev)
6770

6871
platform_set_drvdata(pdev, priv);
6972

73+
ret = of_address_to_resource(np, 0, &res);
74+
if (ret)
75+
return ret;
76+
7077
if (of_property_read_bool(dev->of_node, "mux-controls")) {
7178
struct mux_control *control = devm_mux_control_get(dev, NULL);
7279

@@ -88,6 +95,11 @@ static int am654_hbmc_probe(struct platform_device *pdev)
8895
goto disable_pm;
8996
}
9097

98+
priv->hbdev.map.size = resource_size(&res);
99+
priv->hbdev.map.virt = devm_ioremap_resource(dev, &res);
100+
if (IS_ERR(priv->hbdev.map.virt))
101+
return PTR_ERR(priv->hbdev.map.virt);
102+
91103
priv->ctlr.dev = dev;
92104
priv->ctlr.ops = &am654_hbmc_ops;
93105
priv->hbdev.ctlr = &priv->ctlr;

drivers/mtd/hyperbus/hyperbus-core.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <linux/mtd/map.h>
1111
#include <linux/mtd/mtd.h>
1212
#include <linux/of.h>
13-
#include <linux/of_address.h>
1413
#include <linux/types.h>
1514

1615
static struct hyperbus_device *map_to_hbdev(struct map_info *map)
@@ -62,7 +61,6 @@ int hyperbus_register_device(struct hyperbus_device *hbdev)
6261
struct hyperbus_ctlr *ctlr;
6362
struct device_node *np;
6463
struct map_info *map;
65-
struct resource res;
6664
struct device *dev;
6765
int ret;
6866

@@ -80,17 +78,8 @@ int hyperbus_register_device(struct hyperbus_device *hbdev)
8078

8179
hbdev->memtype = HYPERFLASH;
8280

83-
ret = of_address_to_resource(np, 0, &res);
84-
if (ret)
85-
return ret;
86-
8781
dev = ctlr->dev;
8882
map = &hbdev->map;
89-
map->size = resource_size(&res);
90-
map->virt = devm_ioremap_resource(dev, &res);
91-
if (IS_ERR(map->virt))
92-
return PTR_ERR(map->virt);
93-
9483
map->name = dev_name(dev);
9584
map->bankwidth = 2;
9685
map->device_node = np;

0 commit comments

Comments
 (0)