aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/soc/aspeed/aspeed-lpc-ctrl.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-07-19 20:13:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-19 20:13:56 -0400
commit8362fd64f07eaef7155c94fca8dee91c4f99a666 (patch)
tree2d16af7d7b8cbb5765727493f796d453580fc107 /drivers/soc/aspeed/aspeed-lpc-ctrl.c
parent24e44913aa746098349370a0f279733c0cadcba7 (diff)
parent8c0993621c3e5fa52e5425ef2a0f67a0cde07092 (diff)
Merge tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
Pull ARM SoC-related driver updates from Olof Johansson: "Various driver updates for platforms and a couple of the small driver subsystems we merge through our tree: - A driver for SCU (system control) on NXP i.MX8QXP - Qualcomm Always-on Subsystem messaging driver (AOSS QMP) - Qualcomm PM support for MSM8998 - Support for a newer version of DRAM PHY driver for Broadcom (DPFE) - Reset controller support for Bitmain BM1880 - TI SCI (System Control Interface) support for CPU control on AM654 processors - More TI sysc refactoring and rework" * tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (84 commits) reset: remove redundant null check on pointer dev soc: rockchip: work around clang warning dt-bindings: reset: imx7: Fix the spelling of 'indices' soc: imx: Add i.MX8MN SoC driver support soc: aspeed: lpc-ctrl: Fix probe error handling soc: qcom: geni: Add support for ACPI firmware: ti_sci: Fix gcc unused-but-set-variable warning firmware: ti_sci: Use the correct style for SPDX License Identifier soc: imx8: Use existing of_root directly soc: imx8: Fix potential kernel dump in error path firmware/psci: psci_checker: Park kthreads before stopping them memory: move jedec_ddr.h from include/memory to drivers/memory/ memory: move jedec_ddr_data.c from lib/ to drivers/memory/ MAINTAINERS: Remove myself as qcom maintainer soc: aspeed: lpc-ctrl: make parameter optional soc: qcom: apr: Don't use reg for domain id soc: qcom: fix QCOM_AOSS_QMP dependency and build errors memory: tegra: Fix -Wunused-const-variable firmware: tegra: Early resume BPMP soc/tegra: Select pinctrl for Tegra194 ...
Diffstat (limited to 'drivers/soc/aspeed/aspeed-lpc-ctrl.c')
-rw-r--r--drivers/soc/aspeed/aspeed-lpc-ctrl.c61
1 files changed, 38 insertions, 23 deletions
diff --git a/drivers/soc/aspeed/aspeed-lpc-ctrl.c b/drivers/soc/aspeed/aspeed-lpc-ctrl.c
index 61276ec692f8..01ed21e8bfee 100644
--- a/drivers/soc/aspeed/aspeed-lpc-ctrl.c
+++ b/drivers/soc/aspeed/aspeed-lpc-ctrl.c
@@ -64,6 +64,7 @@ static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd,
64 unsigned long param) 64 unsigned long param)
65{ 65{
66 struct aspeed_lpc_ctrl *lpc_ctrl = file_aspeed_lpc_ctrl(file); 66 struct aspeed_lpc_ctrl *lpc_ctrl = file_aspeed_lpc_ctrl(file);
67 struct device *dev = file->private_data;
67 void __user *p = (void __user *)param; 68 void __user *p = (void __user *)param;
68 struct aspeed_lpc_ctrl_mapping map; 69 struct aspeed_lpc_ctrl_mapping map;
69 u32 addr; 70 u32 addr;
@@ -86,6 +87,12 @@ static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd,
86 if (map.window_id != 0) 87 if (map.window_id != 0)
87 return -EINVAL; 88 return -EINVAL;
88 89
90 /* If memory-region is not described in device tree */
91 if (!lpc_ctrl->mem_size) {
92 dev_dbg(dev, "Didn't find reserved memory\n");
93 return -ENXIO;
94 }
95
89 map.size = lpc_ctrl->mem_size; 96 map.size = lpc_ctrl->mem_size;
90 97
91 return copy_to_user(p, &map, sizeof(map)) ? -EFAULT : 0; 98 return copy_to_user(p, &map, sizeof(map)) ? -EFAULT : 0;
@@ -122,9 +129,18 @@ static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd,
122 return -EINVAL; 129 return -EINVAL;
123 130
124 if (map.window_type == ASPEED_LPC_CTRL_WINDOW_FLASH) { 131 if (map.window_type == ASPEED_LPC_CTRL_WINDOW_FLASH) {
132 if (!lpc_ctrl->pnor_size) {
133 dev_dbg(dev, "Didn't find host pnor flash\n");
134 return -ENXIO;
135 }
125 addr = lpc_ctrl->pnor_base; 136 addr = lpc_ctrl->pnor_base;
126 size = lpc_ctrl->pnor_size; 137 size = lpc_ctrl->pnor_size;
127 } else if (map.window_type == ASPEED_LPC_CTRL_WINDOW_MEMORY) { 138 } else if (map.window_type == ASPEED_LPC_CTRL_WINDOW_MEMORY) {
139 /* If memory-region is not described in device tree */
140 if (!lpc_ctrl->mem_size) {
141 dev_dbg(dev, "Didn't find reserved memory\n");
142 return -ENXIO;
143 }
128 addr = lpc_ctrl->mem_base; 144 addr = lpc_ctrl->mem_base;
129 size = lpc_ctrl->mem_size; 145 size = lpc_ctrl->mem_size;
130 } else { 146 } else {
@@ -192,40 +208,41 @@ static int aspeed_lpc_ctrl_probe(struct platform_device *pdev)
192 if (!lpc_ctrl) 208 if (!lpc_ctrl)
193 return -ENOMEM; 209 return -ENOMEM;
194 210
211 /* If flash is described in device tree then store */
195 node = of_parse_phandle(dev->of_node, "flash", 0); 212 node = of_parse_phandle(dev->of_node, "flash", 0);
196 if (!node) { 213 if (!node) {
197 dev_err(dev, "Didn't find host pnor flash node\n"); 214 dev_dbg(dev, "Didn't find host pnor flash node\n");
198 return -ENODEV; 215 } else {
199 } 216 rc = of_address_to_resource(node, 1, &resm);
217 of_node_put(node);
218 if (rc) {
219 dev_err(dev, "Couldn't address to resource for flash\n");
220 return rc;
221 }
200 222
201 rc = of_address_to_resource(node, 1, &resm); 223 lpc_ctrl->pnor_size = resource_size(&resm);
202 of_node_put(node); 224 lpc_ctrl->pnor_base = resm.start;
203 if (rc) {
204 dev_err(dev, "Couldn't address to resource for flash\n");
205 return rc;
206 } 225 }
207 226
208 lpc_ctrl->pnor_size = resource_size(&resm);
209 lpc_ctrl->pnor_base = resm.start;
210 227
211 dev_set_drvdata(&pdev->dev, lpc_ctrl); 228 dev_set_drvdata(&pdev->dev, lpc_ctrl);
212 229
230 /* If memory-region is described in device tree then store */
213 node = of_parse_phandle(dev->of_node, "memory-region", 0); 231 node = of_parse_phandle(dev->of_node, "memory-region", 0);
214 if (!node) { 232 if (!node) {
215 dev_err(dev, "Didn't find reserved memory\n"); 233 dev_dbg(dev, "Didn't find reserved memory\n");
216 return -EINVAL; 234 } else {
217 } 235 rc = of_address_to_resource(node, 0, &resm);
236 of_node_put(node);
237 if (rc) {
238 dev_err(dev, "Couldn't address to resource for reserved memory\n");
239 return -ENXIO;
240 }
218 241
219 rc = of_address_to_resource(node, 0, &resm); 242 lpc_ctrl->mem_size = resource_size(&resm);
220 of_node_put(node); 243 lpc_ctrl->mem_base = resm.start;
221 if (rc) {
222 dev_err(dev, "Couldn't address to resource for reserved memory\n");
223 return -ENOMEM;
224 } 244 }
225 245
226 lpc_ctrl->mem_size = resource_size(&resm);
227 lpc_ctrl->mem_base = resm.start;
228
229 lpc_ctrl->regmap = syscon_node_to_regmap( 246 lpc_ctrl->regmap = syscon_node_to_regmap(
230 pdev->dev.parent->of_node); 247 pdev->dev.parent->of_node);
231 if (IS_ERR(lpc_ctrl->regmap)) { 248 if (IS_ERR(lpc_ctrl->regmap)) {
@@ -254,8 +271,6 @@ static int aspeed_lpc_ctrl_probe(struct platform_device *pdev)
254 goto err; 271 goto err;
255 } 272 }
256 273
257 dev_info(dev, "Loaded at %pr\n", &resm);
258
259 return 0; 274 return 0;
260 275
261err: 276err: