Lines Matching +full:pd +full:- +full:node
1 // SPDX-License-Identifier: GPL-2.0-only
33 * struct emif_data - Per device static data for driver's use
38 * to this EMIF - read from MR4 register. If there
43 * @node: node in the device list
44 * @base: base address of memory-mapped IO registers.
48 * frequencies, to avoid re-calculating them on
55 * @np_ddr: Pointer to ddr device tree node
61 struct list_head node; member
78 u32 type = emif->plat_data->device_info->type; in do_emif_regdump_show()
79 u32 ip_rev = emif->plat_data->ip_rev; in do_emif_regdump_show()
82 regs->freq/1000000); in do_emif_regdump_show()
84 seq_printf(s, "ref_ctrl_shdw\t: 0x%08x\n", regs->ref_ctrl_shdw); in do_emif_regdump_show()
85 seq_printf(s, "sdram_tim1_shdw\t: 0x%08x\n", regs->sdram_tim1_shdw); in do_emif_regdump_show()
86 seq_printf(s, "sdram_tim2_shdw\t: 0x%08x\n", regs->sdram_tim2_shdw); in do_emif_regdump_show()
87 seq_printf(s, "sdram_tim3_shdw\t: 0x%08x\n", regs->sdram_tim3_shdw); in do_emif_regdump_show()
91 regs->read_idle_ctrl_shdw_normal); in do_emif_regdump_show()
93 regs->read_idle_ctrl_shdw_volt_ramp); in do_emif_regdump_show()
96 regs->dll_calib_ctrl_shdw_normal); in do_emif_regdump_show()
98 regs->dll_calib_ctrl_shdw_volt_ramp); in do_emif_regdump_show()
103 regs->ref_ctrl_shdw_derated); in do_emif_regdump_show()
105 regs->sdram_tim1_shdw_derated); in do_emif_regdump_show()
107 regs->sdram_tim3_shdw_derated); in do_emif_regdump_show()
113 struct emif_data *emif = s->private; in emif_regdump_show()
117 if (emif->duplicate) in emif_regdump_show()
118 regs_cache = emif1->regs_cache; in emif_regdump_show()
120 regs_cache = emif->regs_cache; in emif_regdump_show()
134 struct emif_data *emif = s->private; in emif_mr4_show()
136 seq_printf(s, "MR4=%d\n", emif->temperature_level); in emif_mr4_show()
145 emif->debugfs_root = debugfs_create_dir(dev_name(emif->dev), NULL); in emif_debugfs_init()
146 debugfs_create_file("regcache_dump", S_IRUGO, emif->debugfs_root, emif, in emif_debugfs_init()
148 debugfs_create_file("mr4", S_IRUGO, emif->debugfs_root, emif, in emif_debugfs_init()
156 debugfs_remove_recursive(emif->debugfs_root); in emif_debugfs_exit()
157 emif->debugfs_root = NULL; in emif_debugfs_exit()
163 * bus width of the DDR devices used. For instance two 16-bit DDR devices
170 void __iomem *base = emif->base; in get_emif_bus_width()
182 void __iomem *base = emif->base; in set_lpmode()
185 * Workaround for errata i743 - LPDDR2 Power-Down State is Not in set_lpmode()
189 * The EMIF supports power-down state for low power. The EMIF in set_lpmode()
190 * automatically puts the SDRAM into power-down after the memory is in set_lpmode()
195 * power-down and precharge power-down modes. The EMIF waits and in set_lpmode()
198 * exit of power-down mode. Due to very short periods of power-down in set_lpmode()
201 * issuing ZQ calibration long commands when exiting self-refresh is in set_lpmode()
205 * Because there is no power consumption benefit of the power-down due in set_lpmode()
207 * is to not allow power-down state and, therefore, to not have set in set_lpmode()
210 if ((emif->plat_data->ip_rev == EMIF_4D) && in set_lpmode()
214 /* rollback LP_MODE to Self-refresh mode */ in set_lpmode()
232 * The EMIF automatically puts the SDRAM into self-refresh mode in do_freq_update()
238 * - The SR_TIMING counter expires in do_freq_update()
239 * - And frequency change is requested in do_freq_update()
240 * - And OCP access is requested in do_freq_update()
245 * is to disable the self-refresh when requesting a frequency in do_freq_update()
251 list_for_each_entry(emif, &device_list, node) { in do_freq_update()
252 if (emif->lpmode == EMIF_LP_MODE_SELF_REFRESH) in do_freq_update()
262 list_for_each_entry(emif, &device_list, node) { in do_freq_update()
263 if (emif->lpmode == EMIF_LP_MODE_SELF_REFRESH) in do_freq_update()
274 type = device_info->type; in get_addressing_table()
275 density = device_info->density; in get_addressing_table()
279 index = density - 1; in get_addressing_table()
288 index = density - 1; in get_addressing_table()
303 val = EMIF_ZQCS_INTERVAL_US * 1000 / addressing->tREFI_ns; in get_zq_config_reg()
306 val = DIV_ROUND_UP(T_ZQCL_DEFAULT_NS, T_ZQCS_DEFAULT_NS) - 1; in get_zq_config_reg()
309 val = DIV_ROUND_UP(T_ZQINIT_DEFAULT_NS, T_ZQCL_DEFAULT_NS) - 1; in get_zq_config_reg()
333 if (custom_configs && (custom_configs->mask & in get_temp_alert_config()
335 interval = custom_configs->temp_alert_poll_interval_ms; in get_temp_alert_config()
340 interval /= addressing->tREFI_ns; /* Convert to refresh cycles */ in get_temp_alert_config()
344 * sdram_io_width is in 'log2(x) - 1' form. Convert emif_bus_width in get_temp_alert_config()
348 emif_bus_width = __fls(emif_bus_width) - 1; in get_temp_alert_config()
349 devcnt = emif_bus_width - sdram_io_width; in get_temp_alert_config()
352 /* DEVWDT is in 'log2(x) - 3' form */ in get_temp_alert_config()
353 alert |= (sdram_io_width - 2) << TA_DEVWDT_SHIFT; in get_temp_alert_config()
372 struct emif_custom_configs *cust_cfgs = emif->plat_data->custom_configs; in get_pwr_mgmt_ctrl()
374 if (cust_cfgs && (cust_cfgs->mask & EMIF_CUSTOM_CONFIG_LPMODE)) { in get_pwr_mgmt_ctrl()
375 lpmode = cust_cfgs->lpmode; in get_pwr_mgmt_ctrl()
376 timeout_perf = cust_cfgs->lpmode_timeout_performance; in get_pwr_mgmt_ctrl()
377 timeout_pwr = cust_cfgs->lpmode_timeout_power; in get_pwr_mgmt_ctrl()
378 freq_threshold = cust_cfgs->lpmode_freq_threshold; in get_pwr_mgmt_ctrl()
385 * The value to be set in register is "log2(timeout) - 3" in get_pwr_mgmt_ctrl()
392 if (timeout & (timeout - 1)) in get_pwr_mgmt_ctrl()
394 timeout = __fls(timeout) - 3; in get_pwr_mgmt_ctrl()
422 pr_err("TIMEOUT Overflow - lpmode=%d perf=%d pwr=%d freq=%d\n", in get_pwr_mgmt_ctrl()
458 base = emif->base; in get_temperature_level()
466 if (emif->plat_data->device_info->cs1_used) { in get_temperature_level()
480 emif->temperature_level = temperature_level; in get_temperature_level()
484 * setup_temperature_sensitive_regs() - set the timings for temperature
495 void __iomem *base = emif->base; in setup_temperature_sensitive_regs()
498 type = emif->plat_data->device_info->type; in setup_temperature_sensitive_regs()
500 tim1 = regs->sdram_tim1_shdw; in setup_temperature_sensitive_regs()
501 tim3 = regs->sdram_tim3_shdw; in setup_temperature_sensitive_regs()
502 ref_ctrl = regs->ref_ctrl_shdw; in setup_temperature_sensitive_regs()
504 /* No de-rating for non-lpddr2 devices */ in setup_temperature_sensitive_regs()
508 temperature = emif->temperature_level; in setup_temperature_sensitive_regs()
510 ref_ctrl = regs->ref_ctrl_shdw_derated; in setup_temperature_sensitive_regs()
512 tim1 = regs->sdram_tim1_shdw_derated; in setup_temperature_sensitive_regs()
513 tim3 = regs->sdram_tim3_shdw_derated; in setup_temperature_sensitive_regs()
514 ref_ctrl = regs->ref_ctrl_shdw_derated; in setup_temperature_sensitive_regs()
530 old_temp_level = emif->temperature_level; in handle_temp_alert()
533 if (unlikely(emif->temperature_level == old_temp_level)) { in handle_temp_alert()
535 } else if (!emif->curr_regs) { in handle_temp_alert()
536 dev_err(emif->dev, "temperature alert before registers are calculated, not de-rating timings\n"); in handle_temp_alert()
540 custom_configs = emif->plat_data->custom_configs; in handle_temp_alert()
546 if (custom_configs && !(custom_configs->mask & in handle_temp_alert()
548 if (emif->temperature_level >= SDRAM_TEMP_HIGH_DERATE_REFRESH) { in handle_temp_alert()
549 dev_err(emif->dev, in handle_temp_alert()
551 __func__, emif->temperature_level); in handle_temp_alert()
553 * Temperature far too high - do kernel_power_off() in handle_temp_alert()
556 emif->temperature_level = SDRAM_TEMP_VERY_HIGH_SHUTDOWN; in handle_temp_alert()
561 if (emif->temperature_level < old_temp_level || in handle_temp_alert()
562 emif->temperature_level == SDRAM_TEMP_VERY_HIGH_SHUTDOWN) { in handle_temp_alert()
564 * Temperature coming down - defer handling to thread OR in handle_temp_alert()
565 * Temperature far too high - do kernel_power_off() from in handle_temp_alert()
570 /* Temperature is going up - handle immediately */ in handle_temp_alert()
571 setup_temperature_sensitive_regs(emif, emif->curr_regs); in handle_temp_alert()
583 void __iomem *base = emif->base; in emif_interrupt_handler()
584 struct device *dev = emif->dev; in emif_interrupt_handler()
600 dev_err(dev, "Access error from SYS port - %x\n", interrupts); in emif_interrupt_handler()
602 if (emif->plat_data->hw_caps & EMIF_HW_CAPS_LL_INTERFACE) { in emif_interrupt_handler()
608 dev_err(dev, "Access error from LL port - %x\n", in emif_interrupt_handler()
620 if (emif->temperature_level == SDRAM_TEMP_VERY_HIGH_SHUTDOWN) { in emif_threaded_isr()
621 dev_emerg(emif->dev, "SDRAM temperature exceeds operating limit.. Needs shut down!!!\n"); in emif_threaded_isr()
628 kernel_restart("SDRAM Over-temp Emergency restart"); in emif_threaded_isr()
635 if (emif->curr_regs) { in emif_threaded_isr()
636 setup_temperature_sensitive_regs(emif, emif->curr_regs); in emif_threaded_isr()
639 dev_err(emif->dev, "temperature alert before registers are calculated, not de-rating timings\n"); in emif_threaded_isr()
649 void __iomem *base = emif->base; in clear_all_interrupts()
653 if (emif->plat_data->hw_caps & EMIF_HW_CAPS_LL_INTERFACE) in clear_all_interrupts()
660 void __iomem *base = emif->base; in disable_and_clear_all_interrupts()
665 if (emif->plat_data->hw_caps & EMIF_HW_CAPS_LL_INTERFACE) in disable_and_clear_all_interrupts()
676 void __iomem *base = emif->base; in setup_interrupts()
678 type = emif->plat_data->device_info->type; in setup_interrupts()
689 if (emif->plat_data->hw_caps & EMIF_HW_CAPS_LL_INTERFACE) { in setup_interrupts()
696 return devm_request_threaded_irq(emif->dev, irq, in setup_interrupts()
699 0, dev_name(emif->dev), in setup_interrupts()
707 void __iomem *base = emif->base; in emif_onetime_settings()
711 device_info = emif->plat_data->device_info; in emif_onetime_settings()
720 emif->plat_data->ip_rev); in emif_onetime_settings()
721 emif->lpmode = (pwr_mgmt_ctrl & LP_MODE_MASK) >> LP_MODE_SHIFT; in emif_onetime_settings()
725 zq = get_zq_config_reg(addressing, device_info->cs1_used, in emif_onetime_settings()
726 device_info->cal_resistors_per_cs); in emif_onetime_settings()
731 if (emif->temperature_level == SDRAM_TEMP_VERY_HIGH_SHUTDOWN) in emif_onetime_settings()
732 dev_emerg(emif->dev, "SDRAM temperature exceeds operating limit.. Needs shut down!!!\n"); in emif_onetime_settings()
736 emif->plat_data->custom_configs, device_info->cs1_used, in emif_onetime_settings()
737 device_info->io_width, get_emif_bus_width(emif)); in emif_onetime_settings()
744 if (emif->plat_data->phy_type != EMIF_PHY_TYPE_INTELLIPHY) in emif_onetime_settings()
771 struct emif_platform_data *pd = emif->plat_data; in get_default_timings() local
773 pd->timings = lpddr2_jedec_timings; in get_default_timings()
774 pd->timings_arr_size = ARRAY_SIZE(lpddr2_jedec_timings); in get_default_timings()
776 dev_warn(emif->dev, "%s: using default timings\n", __func__); in get_default_timings()
813 if ((cust_cfgs->mask & EMIF_CUSTOM_CONFIG_LPMODE) && in is_custom_config_valid()
814 (cust_cfgs->lpmode != EMIF_LP_MODE_DISABLE)) in is_custom_config_valid()
815 valid = cust_cfgs->lpmode_freq_threshold && in is_custom_config_valid()
816 cust_cfgs->lpmode_timeout_performance && in is_custom_config_valid()
817 cust_cfgs->lpmode_timeout_power; in is_custom_config_valid()
819 if (cust_cfgs->mask & EMIF_CUSTOM_CONFIG_TEMP_ALERT_POLL_INTERVAL) in is_custom_config_valid()
820 valid = valid && cust_cfgs->temp_alert_poll_interval_ms; in is_custom_config_valid()
835 lpmode = of_get_property(np_emif, "low-power-mode", &len); in of_get_custom_configs()
836 poll_intvl = of_get_property(np_emif, "temp-alert-poll-interval", &len); in of_get_custom_configs()
839 cust_cfgs = devm_kzalloc(emif->dev, sizeof(*cust_cfgs), in of_get_custom_configs()
846 cust_cfgs->mask |= EMIF_CUSTOM_CONFIG_LPMODE; in of_get_custom_configs()
847 cust_cfgs->lpmode = be32_to_cpup(lpmode); in of_get_custom_configs()
849 "low-power-mode-timeout-performance", in of_get_custom_configs()
850 &cust_cfgs->lpmode_timeout_performance); in of_get_custom_configs()
852 "low-power-mode-timeout-power", in of_get_custom_configs()
853 &cust_cfgs->lpmode_timeout_power); in of_get_custom_configs()
855 "low-power-mode-freq-threshold", in of_get_custom_configs()
856 &cust_cfgs->lpmode_freq_threshold); in of_get_custom_configs()
860 cust_cfgs->mask |= in of_get_custom_configs()
862 cust_cfgs->temp_alert_poll_interval_ms = in of_get_custom_configs()
866 if (of_property_read_bool(np_emif, "extended-temp-part")) in of_get_custom_configs()
867 cust_cfgs->mask |= EMIF_CUSTOM_CONFIG_EXTENDED_TEMP_PART; in of_get_custom_configs()
869 if (!is_custom_config_valid(cust_cfgs, emif->dev)) { in of_get_custom_configs()
870 devm_kfree(emif->dev, cust_cfgs); in of_get_custom_configs()
874 emif->plat_data->custom_configs = cust_cfgs; in of_get_custom_configs()
883 dev_info->cs1_used = of_property_read_bool(np_emif, "cs1-used"); in of_get_ddr_info()
884 dev_info->cal_resistors_per_cs = of_property_read_bool(np_emif, "cal-resistor-per-cs"); in of_get_ddr_info()
886 if (of_device_is_compatible(np_ddr, "jedec,lpddr2-s4")) in of_get_ddr_info()
887 dev_info->type = DDR_TYPE_LPDDR2_S4; in of_get_ddr_info()
888 else if (of_device_is_compatible(np_ddr, "jedec,lpddr2-s2")) in of_get_ddr_info()
889 dev_info->type = DDR_TYPE_LPDDR2_S2; in of_get_ddr_info()
892 of_property_read_u32(np_ddr, "io-width", &io_width); in of_get_ddr_info()
895 if (density & (density - 1)) in of_get_ddr_info()
896 dev_info->density = 0; in of_get_ddr_info()
898 dev_info->density = __fls(density) - 5; in of_get_ddr_info()
901 if (io_width & (io_width - 1)) in of_get_ddr_info()
902 dev_info->io_width = 0; in of_get_ddr_info()
904 dev_info->io_width = __fls(io_width) - 1; in of_get_ddr_info()
912 struct emif_platform_data *pd = NULL; in of_get_memory_device_details() local
915 np_ddr = of_parse_phandle(np_emif, "device-handle", 0); in of_get_memory_device_details()
919 pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); in of_get_memory_device_details()
922 if (!emif || !pd || !dev_info) { in of_get_memory_device_details()
928 emif->plat_data = pd; in of_get_memory_device_details()
929 pd->device_info = dev_info; in of_get_memory_device_details()
930 emif->dev = dev; in of_get_memory_device_details()
931 emif->np_ddr = np_ddr; in of_get_memory_device_details()
932 emif->temperature_level = SDRAM_TEMP_NOMINAL; in of_get_memory_device_details()
934 if (of_device_is_compatible(np_emif, "ti,emif-4d")) in of_get_memory_device_details()
935 emif->plat_data->ip_rev = EMIF_4D; in of_get_memory_device_details()
936 else if (of_device_is_compatible(np_emif, "ti,emif-4d5")) in of_get_memory_device_details()
937 emif->plat_data->ip_rev = EMIF_4D5; in of_get_memory_device_details()
939 of_property_read_u32(np_emif, "phy-type", &pd->phy_type); in of_get_memory_device_details()
941 if (of_property_read_bool(np_emif, "hw-caps-ll-interface")) in of_get_memory_device_details()
942 pd->hw_caps |= EMIF_HW_CAPS_LL_INTERFACE; in of_get_memory_device_details()
945 if (!is_dev_data_valid(pd->device_info->type, pd->device_info->density, in of_get_memory_device_details()
946 pd->device_info->io_width, pd->phy_type, pd->ip_rev, in of_get_memory_device_details()
947 emif->dev)) { in of_get_memory_device_details()
957 if (emif1 && emif1->np_ddr == np_ddr) { in of_get_memory_device_details()
958 emif->duplicate = true; in of_get_memory_device_details()
961 dev_warn(emif->dev, "%s: Non-symmetric DDR geometry\n", in of_get_memory_device_details()
966 emif->plat_data->timings = of_get_ddr_timings(np_ddr, emif->dev, in of_get_memory_device_details()
967 emif->plat_data->device_info->type, in of_get_memory_device_details()
968 &emif->plat_data->timings_arr_size); in of_get_memory_device_details()
970 emif->plat_data->min_tck = of_get_min_tck(np_ddr, emif->dev); in of_get_memory_device_details()
986 struct emif_platform_data *pd; in get_device_details() local
990 pd = pdev->dev.platform_data; in get_device_details()
991 dev = &pdev->dev; in get_device_details()
993 if (!(pd && pd->device_info && is_dev_data_valid(pd->device_info->type, in get_device_details()
994 pd->device_info->density, pd->device_info->io_width, in get_device_details()
995 pd->phy_type, pd->ip_rev, dev))) { in get_device_details()
1001 temp = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); in get_device_details()
1007 memcpy(temp, pd, sizeof(*pd)); in get_device_details()
1008 pd = temp; in get_device_details()
1009 memcpy(dev_info, pd->device_info, sizeof(*dev_info)); in get_device_details()
1011 pd->device_info = dev_info; in get_device_details()
1012 emif->plat_data = pd; in get_device_details()
1013 emif->dev = dev; in get_device_details()
1014 emif->temperature_level = SDRAM_TEMP_NOMINAL; in get_device_details()
1022 emif->duplicate = emif1 && (memcmp(dev_info, in get_device_details()
1023 emif1->plat_data->device_info, in get_device_details()
1026 if (emif->duplicate) { in get_device_details()
1027 pd->timings = NULL; in get_device_details()
1028 pd->min_tck = NULL; in get_device_details()
1031 dev_warn(emif->dev, "%s: Non-symmetric DDR geometry\n", in get_device_details()
1036 * Copy custom configs - ignore allocation error, if any, as in get_device_details()
1039 cust_cfgs = pd->custom_configs; in get_device_details()
1044 pd->custom_configs = temp; in get_device_details()
1048 * Copy timings and min-tck values from platform data. If it is not in get_device_details()
1051 size = sizeof(struct lpddr2_timings) * pd->timings_arr_size; in get_device_details()
1052 if (pd->timings) { in get_device_details()
1055 memcpy(temp, pd->timings, size); in get_device_details()
1056 pd->timings = temp; in get_device_details()
1064 if (pd->min_tck) { in get_device_details()
1065 temp = devm_kzalloc(dev, sizeof(*pd->min_tck), GFP_KERNEL); in get_device_details()
1067 memcpy(temp, pd->min_tck, sizeof(*pd->min_tck)); in get_device_details()
1068 pd->min_tck = temp; in get_device_details()
1070 pd->min_tck = &lpddr2_jedec_min_tck; in get_device_details()
1073 pd->min_tck = &lpddr2_jedec_min_tck; in get_device_details()
1088 if (pdev->dev.of_node) in emif_probe()
1089 emif = of_get_memory_device_details(pdev->dev.of_node, &pdev->dev); in emif_probe()
1098 list_add(&emif->node, &device_list); in emif_probe()
1101 emif->dev = &pdev->dev; in emif_probe()
1104 emif->base = devm_platform_ioremap_resource(pdev, 0); in emif_probe()
1105 if (IS_ERR(emif->base)) in emif_probe()
1119 /* One-time actions taken on probing the first device */ in emif_probe()
1130 dev_info(&pdev->dev, "%s: device configured with addr = %p and IRQ%d\n", in emif_probe()
1131 __func__, emif->base, irq); in emif_probe()
1135 return -ENODEV; in emif_probe()
1154 { .compatible = "ti,emif-4d" },
1155 { .compatible = "ti,emif-4d5" },