hbmc-am654.c (aca31ce96814c84d1a41aaa109c15abe61005af7) hbmc-am654.c (992df3bb35a1004f86126d2f80c83450b383f7f4)
1// SPDX-License-Identifier: GPL-2.0
2//
3// Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com/
4// Author: Vignesh Raghavendra <vigneshr@ti.com>
5
6#include <linux/err.h>
7#include <linux/kernel.h>
8#include <linux/module.h>
9#include <linux/mtd/cfi.h>
10#include <linux/mtd/hyperbus.h>
11#include <linux/mtd/mtd.h>
12#include <linux/mux/consumer.h>
13#include <linux/of.h>
14#include <linux/of_address.h>
15#include <linux/platform_device.h>
1// SPDX-License-Identifier: GPL-2.0
2//
3// Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com/
4// Author: Vignesh Raghavendra <vigneshr@ti.com>
5
6#include <linux/err.h>
7#include <linux/kernel.h>
8#include <linux/module.h>
9#include <linux/mtd/cfi.h>
10#include <linux/mtd/hyperbus.h>
11#include <linux/mtd/mtd.h>
12#include <linux/mux/consumer.h>
13#include <linux/of.h>
14#include <linux/of_address.h>
15#include <linux/platform_device.h>
16#include <linux/pm_runtime.h>
17#include <linux/types.h>
18
19#define AM654_HBMC_CALIB_COUNT 25
20
21struct am654_hbmc_priv {
22 struct hyperbus_ctlr ctlr;
23 struct hyperbus_device hbdev;
24 struct mux_control *mux_ctrl;

--- 59 unchanged lines hidden (view full) ---

84 ret = mux_control_select(control, 1);
85 if (ret) {
86 dev_err(dev, "Failed to select HBMC mux\n");
87 return ret;
88 }
89 priv->mux_ctrl = control;
90 }
91
16#include <linux/types.h>
17
18#define AM654_HBMC_CALIB_COUNT 25
19
20struct am654_hbmc_priv {
21 struct hyperbus_ctlr ctlr;
22 struct hyperbus_device hbdev;
23 struct mux_control *mux_ctrl;

--- 59 unchanged lines hidden (view full) ---

83 ret = mux_control_select(control, 1);
84 if (ret) {
85 dev_err(dev, "Failed to select HBMC mux\n");
86 return ret;
87 }
88 priv->mux_ctrl = control;
89 }
90
92 pm_runtime_enable(dev);
93 ret = pm_runtime_get_sync(dev);
94 if (ret < 0) {
95 pm_runtime_put_noidle(dev);
96 goto disable_pm;
97 }
98
99 priv->hbdev.map.size = resource_size(&res);
100 priv->hbdev.map.virt = devm_ioremap_resource(dev, &res);
101 if (IS_ERR(priv->hbdev.map.virt))
102 return PTR_ERR(priv->hbdev.map.virt);
103
104 priv->ctlr.dev = dev;
105 priv->ctlr.ops = &am654_hbmc_ops;
106 priv->hbdev.ctlr = &priv->ctlr;
107 ret = hyperbus_register_device(&priv->hbdev);
108 if (ret) {
109 dev_err(dev, "failed to register controller\n");
91 priv->hbdev.map.size = resource_size(&res);
92 priv->hbdev.map.virt = devm_ioremap_resource(dev, &res);
93 if (IS_ERR(priv->hbdev.map.virt))
94 return PTR_ERR(priv->hbdev.map.virt);
95
96 priv->ctlr.dev = dev;
97 priv->ctlr.ops = &am654_hbmc_ops;
98 priv->hbdev.ctlr = &priv->ctlr;
99 ret = hyperbus_register_device(&priv->hbdev);
100 if (ret) {
101 dev_err(dev, "failed to register controller\n");
110 pm_runtime_put_sync(&pdev->dev);
111 goto disable_pm;
102 goto disable_mux;
112 }
113
114 return 0;
103 }
104
105 return 0;
115disable_pm:
116 pm_runtime_disable(dev);
106disable_mux:
117 if (priv->mux_ctrl)
118 mux_control_deselect(priv->mux_ctrl);
119 return ret;
120}
121
122static int am654_hbmc_remove(struct platform_device *pdev)
123{
124 struct am654_hbmc_priv *priv = platform_get_drvdata(pdev);
125 int ret;
126
127 ret = hyperbus_unregister_device(&priv->hbdev);
128 if (priv->mux_ctrl)
129 mux_control_deselect(priv->mux_ctrl);
107 if (priv->mux_ctrl)
108 mux_control_deselect(priv->mux_ctrl);
109 return ret;
110}
111
112static int am654_hbmc_remove(struct platform_device *pdev)
113{
114 struct am654_hbmc_priv *priv = platform_get_drvdata(pdev);
115 int ret;
116
117 ret = hyperbus_unregister_device(&priv->hbdev);
118 if (priv->mux_ctrl)
119 mux_control_deselect(priv->mux_ctrl);
130 pm_runtime_put_sync(&pdev->dev);
131 pm_runtime_disable(&pdev->dev);
132
133 return ret;
134}
135
136static const struct of_device_id am654_hbmc_dt_ids[] = {
137 {
138 .compatible = "ti,am654-hbmc",
139 },

--- 20 unchanged lines hidden ---
120
121 return ret;
122}
123
124static const struct of_device_id am654_hbmc_dt_ids[] = {
125 {
126 .compatible = "ti,am654-hbmc",
127 },

--- 20 unchanged lines hidden ---