Skip to content

Commit

Permalink
mtd: hyperbus: move direct mapping setup to AM654 HBMC driver
Browse files Browse the repository at this point in the history
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 <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
  • Loading branch information
Sergei Shtylyov authored and Vignesh Raghavendra committed Mar 3, 2020
1 parent cb6176e commit b6fe8bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
12 changes: 12 additions & 0 deletions drivers/mtd/hyperbus/hbmc-am654.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mux/consumer.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/types.h>
Expand Down Expand Up @@ -57,8 +58,10 @@ static const struct hyperbus_ops am654_hbmc_ops = {

static int am654_hbmc_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct device *dev = &pdev->dev;
struct am654_hbmc_priv *priv;
struct resource res;
int ret;

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

platform_set_drvdata(pdev, priv);

ret = of_address_to_resource(np, 0, &res);
if (ret)
return ret;

if (of_property_read_bool(dev->of_node, "mux-controls")) {
struct mux_control *control = devm_mux_control_get(dev, NULL);

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

priv->hbdev.map.size = resource_size(&res);
priv->hbdev.map.virt = devm_ioremap_resource(dev, &res);
if (IS_ERR(priv->hbdev.map.virt))
return PTR_ERR(priv->hbdev.map.virt);

priv->ctlr.dev = dev;
priv->ctlr.ops = &am654_hbmc_ops;
priv->hbdev.ctlr = &priv->ctlr;
Expand Down
11 changes: 0 additions & 11 deletions drivers/mtd/hyperbus/hyperbus-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <linux/mtd/map.h>
#include <linux/mtd/mtd.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/types.h>

static struct hyperbus_device *map_to_hbdev(struct map_info *map)
Expand Down Expand Up @@ -62,7 +61,6 @@ int hyperbus_register_device(struct hyperbus_device *hbdev)
struct hyperbus_ctlr *ctlr;
struct device_node *np;
struct map_info *map;
struct resource res;
struct device *dev;
int ret;

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

hbdev->memtype = HYPERFLASH;

ret = of_address_to_resource(np, 0, &res);
if (ret)
return ret;

dev = ctlr->dev;
map = &hbdev->map;
map->size = resource_size(&res);
map->virt = devm_ioremap_resource(dev, &res);
if (IS_ERR(map->virt))
return PTR_ERR(map->virt);

map->name = dev_name(dev);
map->bankwidth = 2;
map->device_node = np;
Expand Down

0 comments on commit b6fe8bc

Please sign in to comment.