Lines Matching +full:ast2500 +full:- +full:lpc

1 // SPDX-License-Identifier: GPL-2.0-or-later
16 #include <linux/aspeed-lpc-ctrl.h>
18 #define DEVICE_NAME "aspeed-lpc-ctrl"
39 return container_of(file->private_data, struct aspeed_lpc_ctrl, in file_aspeed_lpc_ctrl()
46 unsigned long vsize = vma->vm_end - vma->vm_start; in aspeed_lpc_ctrl_mmap()
47 pgprot_t prot = vma->vm_page_prot; in aspeed_lpc_ctrl_mmap()
49 if (vma->vm_pgoff + vsize > lpc_ctrl->mem_base + lpc_ctrl->mem_size) in aspeed_lpc_ctrl_mmap()
50 return -EINVAL; in aspeed_lpc_ctrl_mmap()
55 if (remap_pfn_range(vma, vma->vm_start, in aspeed_lpc_ctrl_mmap()
56 (lpc_ctrl->mem_base >> PAGE_SHIFT) + vma->vm_pgoff, in aspeed_lpc_ctrl_mmap()
58 return -EAGAIN; in aspeed_lpc_ctrl_mmap()
67 struct device *dev = file->private_data; in aspeed_lpc_ctrl_ioctl()
75 return -EFAULT; in aspeed_lpc_ctrl_ioctl()
78 return -EINVAL; in aspeed_lpc_ctrl_ioctl()
84 return -EINVAL; in aspeed_lpc_ctrl_ioctl()
88 return -EINVAL; in aspeed_lpc_ctrl_ioctl()
90 /* If memory-region is not described in device tree */ in aspeed_lpc_ctrl_ioctl()
91 if (!lpc_ctrl->mem_size) { in aspeed_lpc_ctrl_ioctl()
93 return -ENXIO; in aspeed_lpc_ctrl_ioctl()
96 map.size = lpc_ctrl->mem_size; in aspeed_lpc_ctrl_ioctl()
98 return copy_to_user(p, &map, sizeof(map)) ? -EFAULT : 0; in aspeed_lpc_ctrl_ioctl()
104 * The bottom half of HICR7 is the MSB of the HOST LPC in aspeed_lpc_ctrl_ioctl()
122 return -EINVAL; in aspeed_lpc_ctrl_ioctl()
128 if (map.offset & (map.size - 1)) in aspeed_lpc_ctrl_ioctl()
129 return -EINVAL; in aspeed_lpc_ctrl_ioctl()
132 if (!lpc_ctrl->pnor_size) { in aspeed_lpc_ctrl_ioctl()
134 return -ENXIO; in aspeed_lpc_ctrl_ioctl()
136 addr = lpc_ctrl->pnor_base; in aspeed_lpc_ctrl_ioctl()
137 size = lpc_ctrl->pnor_size; in aspeed_lpc_ctrl_ioctl()
139 /* If memory-region is not described in device tree */ in aspeed_lpc_ctrl_ioctl()
140 if (!lpc_ctrl->mem_size) { in aspeed_lpc_ctrl_ioctl()
142 return -ENXIO; in aspeed_lpc_ctrl_ioctl()
144 addr = lpc_ctrl->mem_base; in aspeed_lpc_ctrl_ioctl()
145 size = lpc_ctrl->mem_size; in aspeed_lpc_ctrl_ioctl()
147 return -EINVAL; in aspeed_lpc_ctrl_ioctl()
153 return -EINVAL; in aspeed_lpc_ctrl_ioctl()
156 return -EINVAL; in aspeed_lpc_ctrl_ioctl()
161 * addr (host lpc address) is safe regardless of values. This in aspeed_lpc_ctrl_ioctl()
163 * side of the LPC bus. This cannot impact the hosts own in aspeed_lpc_ctrl_ioctl()
164 * memory space by surprise as LPC specific accessors are in aspeed_lpc_ctrl_ioctl()
169 rc = regmap_write(lpc_ctrl->regmap, HICR7, in aspeed_lpc_ctrl_ioctl()
174 rc = regmap_write(lpc_ctrl->regmap, HICR8, in aspeed_lpc_ctrl_ioctl()
175 (~(map.size - 1)) | ((map.size >> 16) - 1)); in aspeed_lpc_ctrl_ioctl()
180 * Enable LPC FHW cycles. This is required for the host to in aspeed_lpc_ctrl_ioctl()
183 return regmap_update_bits(lpc_ctrl->regmap, HICR5, in aspeed_lpc_ctrl_ioctl()
188 return -EINVAL; in aspeed_lpc_ctrl_ioctl()
205 dev = &pdev->dev; in aspeed_lpc_ctrl_probe()
209 return -ENOMEM; in aspeed_lpc_ctrl_probe()
212 node = of_parse_phandle(dev->of_node, "flash", 0); in aspeed_lpc_ctrl_probe()
223 lpc_ctrl->pnor_size = resource_size(&resm); in aspeed_lpc_ctrl_probe()
224 lpc_ctrl->pnor_base = resm.start; in aspeed_lpc_ctrl_probe()
228 dev_set_drvdata(&pdev->dev, lpc_ctrl); in aspeed_lpc_ctrl_probe()
230 /* If memory-region is described in device tree then store */ in aspeed_lpc_ctrl_probe()
231 node = of_parse_phandle(dev->of_node, "memory-region", 0); in aspeed_lpc_ctrl_probe()
239 return -ENXIO; in aspeed_lpc_ctrl_probe()
242 lpc_ctrl->mem_size = resource_size(&resm); in aspeed_lpc_ctrl_probe()
243 lpc_ctrl->mem_base = resm.start; in aspeed_lpc_ctrl_probe()
246 lpc_ctrl->regmap = syscon_node_to_regmap( in aspeed_lpc_ctrl_probe()
247 pdev->dev.parent->of_node); in aspeed_lpc_ctrl_probe()
248 if (IS_ERR(lpc_ctrl->regmap)) { in aspeed_lpc_ctrl_probe()
250 return -ENODEV; in aspeed_lpc_ctrl_probe()
253 lpc_ctrl->clk = devm_clk_get(dev, NULL); in aspeed_lpc_ctrl_probe()
254 if (IS_ERR(lpc_ctrl->clk)) { in aspeed_lpc_ctrl_probe()
256 return PTR_ERR(lpc_ctrl->clk); in aspeed_lpc_ctrl_probe()
258 rc = clk_prepare_enable(lpc_ctrl->clk); in aspeed_lpc_ctrl_probe()
264 lpc_ctrl->miscdev.minor = MISC_DYNAMIC_MINOR; in aspeed_lpc_ctrl_probe()
265 lpc_ctrl->miscdev.name = DEVICE_NAME; in aspeed_lpc_ctrl_probe()
266 lpc_ctrl->miscdev.fops = &aspeed_lpc_ctrl_fops; in aspeed_lpc_ctrl_probe()
267 lpc_ctrl->miscdev.parent = dev; in aspeed_lpc_ctrl_probe()
268 rc = misc_register(&lpc_ctrl->miscdev); in aspeed_lpc_ctrl_probe()
277 clk_disable_unprepare(lpc_ctrl->clk); in aspeed_lpc_ctrl_probe()
283 struct aspeed_lpc_ctrl *lpc_ctrl = dev_get_drvdata(&pdev->dev); in aspeed_lpc_ctrl_remove()
285 misc_deregister(&lpc_ctrl->miscdev); in aspeed_lpc_ctrl_remove()
286 clk_disable_unprepare(lpc_ctrl->clk); in aspeed_lpc_ctrl_remove()
292 { .compatible = "aspeed,ast2400-lpc-ctrl" },
293 { .compatible = "aspeed,ast2500-lpc-ctrl" },
311 MODULE_DESCRIPTION("Control for aspeed 2400/2500 LPC HOST to BMC mappings");