Lines Matching +full:device +full:- +full:sram
1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI AM33XX SRAM EMIF Driver
5 * Copyright (C) 2016-2017 Texas Instruments Inc.
17 #include <linux/sram.h>
18 #include <linux/ti-emif-sram.h>
22 #define TI_EMIF_SRAM_SYMBOL_OFFSET(sym) ((unsigned long)(sym) - \
43 return (emif_data->ti_emif_sram_virt + in sram_suspend_address()
50 return ((unsigned long)emif_data->ti_emif_sram_phys + in sram_resume_address()
56 gen_pool_free(emif_data->sram_pool_code, emif_data->ti_emif_sram_virt, in ti_emif_free_sram()
58 gen_pool_free(emif_data->sram_pool_data, in ti_emif_free_sram()
59 emif_data->ti_emif_sram_data_virt, in ti_emif_free_sram()
63 static int ti_emif_alloc_sram(struct device *dev, in ti_emif_alloc_sram()
66 struct device_node *np = dev->of_node; in ti_emif_alloc_sram()
69 emif_data->sram_pool_code = of_gen_pool_get(np, "sram", 0); in ti_emif_alloc_sram()
70 if (!emif_data->sram_pool_code) { in ti_emif_alloc_sram()
71 dev_err(dev, "Unable to get sram pool for ocmcram code\n"); in ti_emif_alloc_sram()
72 return -ENODEV; in ti_emif_alloc_sram()
75 emif_data->ti_emif_sram_virt = in ti_emif_alloc_sram()
76 gen_pool_alloc(emif_data->sram_pool_code, in ti_emif_alloc_sram()
78 if (!emif_data->ti_emif_sram_virt) { in ti_emif_alloc_sram()
80 return -ENOMEM; in ti_emif_alloc_sram()
84 emif_data->ti_emif_sram_phys = in ti_emif_alloc_sram()
85 gen_pool_virt_to_phys(emif_data->sram_pool_code, in ti_emif_alloc_sram()
86 emif_data->ti_emif_sram_virt); in ti_emif_alloc_sram()
88 /* Get sram pool for data section and allocate space */ in ti_emif_alloc_sram()
89 emif_data->sram_pool_data = of_gen_pool_get(np, "sram", 1); in ti_emif_alloc_sram()
90 if (!emif_data->sram_pool_data) { in ti_emif_alloc_sram()
91 dev_err(dev, "Unable to get sram pool for ocmcram data\n"); in ti_emif_alloc_sram()
92 ret = -ENODEV; in ti_emif_alloc_sram()
96 emif_data->ti_emif_sram_data_virt = in ti_emif_alloc_sram()
97 gen_pool_alloc(emif_data->sram_pool_data, in ti_emif_alloc_sram()
99 if (!emif_data->ti_emif_sram_data_virt) { in ti_emif_alloc_sram()
101 ret = -ENOMEM; in ti_emif_alloc_sram()
106 emif_data->ti_emif_sram_data_phys = in ti_emif_alloc_sram()
107 gen_pool_virt_to_phys(emif_data->sram_pool_data, in ti_emif_alloc_sram()
108 emif_data->ti_emif_sram_data_virt); in ti_emif_alloc_sram()
113 emif_data->pm_functions.save_context = in ti_emif_alloc_sram()
116 emif_data->pm_functions.enter_sr = in ti_emif_alloc_sram()
119 emif_data->pm_functions.abort_sr = in ti_emif_alloc_sram()
127 emif_data->pm_functions.restore_context = in ti_emif_alloc_sram()
130 emif_data->pm_functions.exit_sr = in ti_emif_alloc_sram()
133 emif_data->pm_functions.run_hw_leveling = in ti_emif_alloc_sram()
137 emif_data->pm_data.regs_virt = in ti_emif_alloc_sram()
138 (struct emif_regs_amx3 *)emif_data->ti_emif_sram_data_virt; in ti_emif_alloc_sram()
139 emif_data->pm_data.regs_phys = emif_data->ti_emif_sram_data_phys; in ti_emif_alloc_sram()
144 gen_pool_free(emif_data->sram_pool_code, emif_data->ti_emif_sram_virt, in ti_emif_alloc_sram()
149 static int ti_emif_push_sram(struct device *dev, struct ti_emif_data *emif_data) in ti_emif_push_sram()
154 copy_addr = sram_exec_copy(emif_data->sram_pool_code, in ti_emif_push_sram()
155 (void *)emif_data->ti_emif_sram_virt, in ti_emif_push_sram()
158 dev_err(dev, "Cannot copy emif code to sram\n"); in ti_emif_push_sram()
159 return -ENODEV; in ti_emif_push_sram()
164 copy_addr = sram_exec_copy(emif_data->sram_pool_code, in ti_emif_push_sram()
166 &emif_data->pm_data, in ti_emif_push_sram()
167 sizeof(emif_data->pm_data)); in ti_emif_push_sram()
169 dev_err(dev, "Cannot copy emif data to code sram\n"); in ti_emif_push_sram()
170 return -ENODEV; in ti_emif_push_sram()
178 * Self-Refresh Command Limit" found in AM335x Silicon Errata
186 (emif_data->pm_data.ti_emif_base_addr_virt + in ti_emif_configure_sr_delay()
190 (emif_data->pm_data.ti_emif_base_addr_virt + in ti_emif_configure_sr_delay()
195 * ti_emif_copy_pm_function_table - copy mapping of pm funcs in sram
206 return -ENODEV; in ti_emif_copy_pm_function_table()
209 &emif_instance->pm_functions, in ti_emif_copy_pm_function_table()
210 sizeof(emif_instance->pm_functions)); in ti_emif_copy_pm_function_table()
212 return -ENODEV; in ti_emif_copy_pm_function_table()
219 * ti_emif_get_mem_type - return type for memory type in use
228 return -ENODEV; in ti_emif_get_mem_type()
230 temp = readl(emif_instance->pm_data.ti_emif_base_addr_virt + in ti_emif_get_mem_type()
239 { .compatible = "ti,emif-am3352", .data =
241 { .compatible = "ti,emif-am4372", .data =
248 static int ti_emif_resume(struct device *dev) in ti_emif_resume()
251 __raw_readl((void __iomem *)emif_instance->ti_emif_sram_virt); in ti_emif_resume()
256 * indicates we have lost context and sram no longer contains in ti_emif_resume()
265 static int ti_emif_suspend(struct device *dev) in ti_emif_suspend()
279 struct device *dev = &pdev->dev; in ti_emif_probe()
284 return -ENOMEM; in ti_emif_probe()
286 emif_data->pm_data.ti_emif_sram_config = (unsigned long) device_get_match_data(&pdev->dev); in ti_emif_probe()
288 emif_data->pm_data.ti_emif_base_addr_virt = devm_platform_get_and_ioremap_resource(pdev, in ti_emif_probe()
291 if (IS_ERR(emif_data->pm_data.ti_emif_base_addr_virt)) { in ti_emif_probe()
292 ret = PTR_ERR(emif_data->pm_data.ti_emif_base_addr_virt); in ti_emif_probe()
296 emif_data->pm_data.ti_emif_base_addr_phys = res->start; in ti_emif_probe()
344 MODULE_AUTHOR("Dave Gerlach <d-gerlach@ti.com>");
345 MODULE_DESCRIPTION("Texas Instruments SRAM EMIF driver");