Lines Matching +full:fmc2 +full:- +full:ebi +full:- +full:cs +full:- +full:wait +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0
17 /* FMC2 Controller Registers */
148 * struct stm32_fmc2_prop - STM32 FMC2 EBI property
171 int (*check)(struct stm32_fmc2_ebi *ebi,
172 const struct stm32_fmc2_prop *prop, int cs);
173 u32 (*calculate)(struct stm32_fmc2_ebi *ebi, int cs, u32 setup);
174 int (*set)(struct stm32_fmc2_ebi *ebi,
176 int cs, u32 setup);
179 static int stm32_fmc2_ebi_check_mux(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_mux() argument
181 int cs) in stm32_fmc2_ebi_check_mux() argument
186 ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_mux()
193 return -EINVAL; in stm32_fmc2_ebi_check_mux()
196 static int stm32_fmc2_ebi_check_waitcfg(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_waitcfg() argument
198 int cs) in stm32_fmc2_ebi_check_waitcfg() argument
203 ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_waitcfg()
210 return -EINVAL; in stm32_fmc2_ebi_check_waitcfg()
213 static int stm32_fmc2_ebi_check_sync_trans(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_sync_trans() argument
215 int cs) in stm32_fmc2_ebi_check_sync_trans() argument
220 ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_sync_trans()
227 return -EINVAL; in stm32_fmc2_ebi_check_sync_trans()
230 static int stm32_fmc2_ebi_check_async_trans(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_async_trans() argument
232 int cs) in stm32_fmc2_ebi_check_async_trans() argument
237 ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_async_trans()
244 return -EINVAL; in stm32_fmc2_ebi_check_async_trans()
247 static int stm32_fmc2_ebi_check_cpsize(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_cpsize() argument
249 int cs) in stm32_fmc2_ebi_check_cpsize() argument
254 ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_cpsize()
261 return -EINVAL; in stm32_fmc2_ebi_check_cpsize()
264 static int stm32_fmc2_ebi_check_address_hold(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_address_hold() argument
266 int cs) in stm32_fmc2_ebi_check_address_hold() argument
271 ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_address_hold()
275 if (prop->reg_type == FMC2_REG_BWTR) in stm32_fmc2_ebi_check_address_hold()
276 ret = regmap_read(ebi->regmap, FMC2_BWTR(cs), &bxtr); in stm32_fmc2_ebi_check_address_hold()
278 ret = regmap_read(ebi->regmap, FMC2_BTR(cs), &bxtr); in stm32_fmc2_ebi_check_address_hold()
286 return -EINVAL; in stm32_fmc2_ebi_check_address_hold()
289 static int stm32_fmc2_ebi_check_clk_period(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_clk_period() argument
291 int cs) in stm32_fmc2_ebi_check_clk_period() argument
296 ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_check_clk_period()
300 if (cs) { in stm32_fmc2_ebi_check_clk_period()
301 ret = regmap_read(ebi->regmap, FMC2_BCR1, &bcr1); in stm32_fmc2_ebi_check_clk_period()
308 if (bcr & FMC2_BCR_BURSTEN && (!cs || !(bcr1 & FMC2_BCR1_CCLKEN))) in stm32_fmc2_ebi_check_clk_period()
311 return -EINVAL; in stm32_fmc2_ebi_check_clk_period()
314 static int stm32_fmc2_ebi_check_cclk(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_check_cclk() argument
316 int cs) in stm32_fmc2_ebi_check_cclk() argument
318 if (cs) in stm32_fmc2_ebi_check_cclk()
319 return -EINVAL; in stm32_fmc2_ebi_check_cclk()
321 return stm32_fmc2_ebi_check_sync_trans(ebi, prop, cs); in stm32_fmc2_ebi_check_cclk()
324 static u32 stm32_fmc2_ebi_ns_to_clock_cycles(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_ns_to_clock_cycles() argument
325 int cs, u32 setup) in stm32_fmc2_ebi_ns_to_clock_cycles() argument
327 unsigned long hclk = clk_get_rate(ebi->clk); in stm32_fmc2_ebi_ns_to_clock_cycles()
333 static u32 stm32_fmc2_ebi_ns_to_clk_period(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_ns_to_clk_period() argument
334 int cs, u32 setup) in stm32_fmc2_ebi_ns_to_clk_period() argument
336 u32 nb_clk_cycles = stm32_fmc2_ebi_ns_to_clock_cycles(ebi, cs, setup); in stm32_fmc2_ebi_ns_to_clk_period()
340 ret = regmap_read(ebi->regmap, FMC2_BCR1, &bcr); in stm32_fmc2_ebi_ns_to_clk_period()
344 if (bcr & FMC2_BCR1_CCLKEN || !cs) in stm32_fmc2_ebi_ns_to_clk_period()
345 ret = regmap_read(ebi->regmap, FMC2_BTR1, &btr); in stm32_fmc2_ebi_ns_to_clk_period()
347 ret = regmap_read(ebi->regmap, FMC2_BTR(cs), &btr); in stm32_fmc2_ebi_ns_to_clk_period()
356 static int stm32_fmc2_ebi_get_reg(int reg_type, int cs, u32 *reg) in stm32_fmc2_ebi_get_reg() argument
360 *reg = FMC2_BCR(cs); in stm32_fmc2_ebi_get_reg()
363 *reg = FMC2_BTR(cs); in stm32_fmc2_ebi_get_reg()
366 *reg = FMC2_BWTR(cs); in stm32_fmc2_ebi_get_reg()
372 return -EINVAL; in stm32_fmc2_ebi_get_reg()
378 static int stm32_fmc2_ebi_set_bit_field(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_bit_field() argument
380 int cs, u32 setup) in stm32_fmc2_ebi_set_bit_field() argument
385 ret = stm32_fmc2_ebi_get_reg(prop->reg_type, cs, &reg); in stm32_fmc2_ebi_set_bit_field()
389 regmap_update_bits(ebi->regmap, reg, prop->reg_mask, in stm32_fmc2_ebi_set_bit_field()
390 setup ? prop->reg_mask : 0); in stm32_fmc2_ebi_set_bit_field()
395 static int stm32_fmc2_ebi_set_trans_type(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_trans_type() argument
397 int cs, u32 setup) in stm32_fmc2_ebi_set_trans_type() argument
516 return -EINVAL; in stm32_fmc2_ebi_set_trans_type()
520 regmap_update_bits(ebi->regmap, FMC2_BWTR(cs), in stm32_fmc2_ebi_set_trans_type()
522 regmap_update_bits(ebi->regmap, FMC2_BTR(cs), btr_mask, btr); in stm32_fmc2_ebi_set_trans_type()
523 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), bcr_mask, bcr); in stm32_fmc2_ebi_set_trans_type()
528 static int stm32_fmc2_ebi_set_buswidth(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_buswidth() argument
530 int cs, u32 setup) in stm32_fmc2_ebi_set_buswidth() argument
543 return -EINVAL; in stm32_fmc2_ebi_set_buswidth()
546 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), FMC2_BCR_MWID, val); in stm32_fmc2_ebi_set_buswidth()
551 static int stm32_fmc2_ebi_set_cpsize(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_cpsize() argument
553 int cs, u32 setup) in stm32_fmc2_ebi_set_cpsize() argument
575 return -EINVAL; in stm32_fmc2_ebi_set_cpsize()
578 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), FMC2_BCR_CPSIZE, val); in stm32_fmc2_ebi_set_cpsize()
583 static int stm32_fmc2_ebi_set_bl_setup(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_bl_setup() argument
585 int cs, u32 setup) in stm32_fmc2_ebi_set_bl_setup() argument
591 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), FMC2_BCR_NBLSET, val); in stm32_fmc2_ebi_set_bl_setup()
596 static int stm32_fmc2_ebi_set_address_setup(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_address_setup() argument
598 int cs, u32 setup) in stm32_fmc2_ebi_set_address_setup() argument
604 ret = stm32_fmc2_ebi_get_reg(prop->reg_type, cs, &reg); in stm32_fmc2_ebi_set_address_setup()
608 ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_set_address_setup()
612 if (prop->reg_type == FMC2_REG_BWTR) in stm32_fmc2_ebi_set_address_setup()
613 ret = regmap_read(ebi->regmap, FMC2_BWTR(cs), &bxtr); in stm32_fmc2_ebi_set_address_setup()
615 ret = regmap_read(ebi->regmap, FMC2_BTR(cs), &bxtr); in stm32_fmc2_ebi_set_address_setup()
624 regmap_update_bits(ebi->regmap, reg, FMC2_BXTR_ADDSET, val); in stm32_fmc2_ebi_set_address_setup()
629 static int stm32_fmc2_ebi_set_address_hold(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_address_hold() argument
631 int cs, u32 setup) in stm32_fmc2_ebi_set_address_hold() argument
636 ret = stm32_fmc2_ebi_get_reg(prop->reg_type, cs, &reg); in stm32_fmc2_ebi_set_address_hold()
642 regmap_update_bits(ebi->regmap, reg, FMC2_BXTR_ADDHLD, val); in stm32_fmc2_ebi_set_address_hold()
647 static int stm32_fmc2_ebi_set_data_setup(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_data_setup() argument
649 int cs, u32 setup) in stm32_fmc2_ebi_set_data_setup() argument
654 ret = stm32_fmc2_ebi_get_reg(prop->reg_type, cs, &reg); in stm32_fmc2_ebi_set_data_setup()
660 regmap_update_bits(ebi->regmap, reg, FMC2_BXTR_DATAST, val); in stm32_fmc2_ebi_set_data_setup()
665 static int stm32_fmc2_ebi_set_bus_turnaround(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_bus_turnaround() argument
667 int cs, u32 setup) in stm32_fmc2_ebi_set_bus_turnaround() argument
672 ret = stm32_fmc2_ebi_get_reg(prop->reg_type, cs, &reg); in stm32_fmc2_ebi_set_bus_turnaround()
676 val = setup ? min_t(u32, setup - 1, FMC2_BXTR_BUSTURN_MAX) : 0; in stm32_fmc2_ebi_set_bus_turnaround()
678 regmap_update_bits(ebi->regmap, reg, FMC2_BXTR_BUSTURN, val); in stm32_fmc2_ebi_set_bus_turnaround()
683 static int stm32_fmc2_ebi_set_data_hold(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_data_hold() argument
685 int cs, u32 setup) in stm32_fmc2_ebi_set_data_hold() argument
690 ret = stm32_fmc2_ebi_get_reg(prop->reg_type, cs, &reg); in stm32_fmc2_ebi_set_data_hold()
694 if (prop->reg_type == FMC2_REG_BWTR) in stm32_fmc2_ebi_set_data_hold()
695 val = setup ? min_t(u32, setup - 1, FMC2_BXTR_DATAHLD_MAX) : 0; in stm32_fmc2_ebi_set_data_hold()
699 regmap_update_bits(ebi->regmap, reg, FMC2_BXTR_DATAHLD, val); in stm32_fmc2_ebi_set_data_hold()
704 static int stm32_fmc2_ebi_set_clk_period(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_clk_period() argument
706 int cs, u32 setup) in stm32_fmc2_ebi_set_clk_period() argument
710 val = setup ? clamp_val(setup - 1, 1, FMC2_BTR_CLKDIV_MAX) : 1; in stm32_fmc2_ebi_set_clk_period()
712 regmap_update_bits(ebi->regmap, FMC2_BTR(cs), FMC2_BTR_CLKDIV, val); in stm32_fmc2_ebi_set_clk_period()
717 static int stm32_fmc2_ebi_set_data_latency(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_data_latency() argument
719 int cs, u32 setup) in stm32_fmc2_ebi_set_data_latency() argument
723 val = setup > 1 ? min_t(u32, setup - 2, FMC2_BTR_DATLAT_MAX) : 0; in stm32_fmc2_ebi_set_data_latency()
725 regmap_update_bits(ebi->regmap, FMC2_BTR(cs), FMC2_BTR_DATLAT, val); in stm32_fmc2_ebi_set_data_latency()
730 static int stm32_fmc2_ebi_set_max_low_pulse(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_set_max_low_pulse() argument
732 int cs, u32 setup) in stm32_fmc2_ebi_set_max_low_pulse() argument
740 ret = regmap_read(ebi->regmap, FMC2_PCSCNTR, &pcscntr); in stm32_fmc2_ebi_set_max_low_pulse()
744 /* Enable counter for the bank */ in stm32_fmc2_ebi_set_max_low_pulse()
745 regmap_update_bits(ebi->regmap, FMC2_PCSCNTR, in stm32_fmc2_ebi_set_max_low_pulse()
746 FMC2_PCSCNTR_CNTBEN(cs), in stm32_fmc2_ebi_set_max_low_pulse()
747 FMC2_PCSCNTR_CNTBEN(cs)); in stm32_fmc2_ebi_set_max_low_pulse()
749 new_val = min_t(u32, setup - 1, FMC2_PCSCNTR_CSCOUNT_MAX); in stm32_fmc2_ebi_set_max_low_pulse()
756 regmap_update_bits(ebi->regmap, FMC2_PCSCNTR, in stm32_fmc2_ebi_set_max_low_pulse()
763 /* st,fmc2-ebi-cs-trans-type must be the first property */
765 .name = "st,fmc2-ebi-cs-transaction-type",
770 .name = "st,fmc2-ebi-cs-cclk-enable",
778 .name = "st,fmc2-ebi-cs-mux-enable",
786 .name = "st,fmc2-ebi-cs-buswidth",
791 .name = "st,fmc2-ebi-cs-waitpol-high",
798 .name = "st,fmc2-ebi-cs-waitcfg-enable",
806 .name = "st,fmc2-ebi-cs-wait-enable",
814 .name = "st,fmc2-ebi-cs-asyncwait-enable",
822 .name = "st,fmc2-ebi-cs-cpsize",
827 .name = "st,fmc2-ebi-cs-byte-lane-setup-ns",
832 .name = "st,fmc2-ebi-cs-address-setup-ns",
840 .name = "st,fmc2-ebi-cs-address-hold-ns",
848 .name = "st,fmc2-ebi-cs-data-setup-ns",
856 .name = "st,fmc2-ebi-cs-bus-turnaround-ns",
863 .name = "st,fmc2-ebi-cs-data-hold-ns",
870 .name = "st,fmc2-ebi-cs-clk-period-ns",
877 .name = "st,fmc2-ebi-cs-data-latency-ns",
883 .name = "st,fmc2-ebi-cs-write-address-setup-ns",
891 .name = "st,fmc2-ebi-cs-write-address-hold-ns",
899 .name = "st,fmc2-ebi-cs-write-data-setup-ns",
907 .name = "st,fmc2-ebi-cs-write-bus-turnaround-ns",
914 .name = "st,fmc2-ebi-cs-write-data-hold-ns",
921 .name = "st,fmc2-ebi-cs-max-low-pulse-ns",
927 static int stm32_fmc2_ebi_parse_prop(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_parse_prop() argument
930 int cs) in stm32_fmc2_ebi_parse_prop() argument
932 struct device *dev = ebi->dev; in stm32_fmc2_ebi_parse_prop()
935 if (!prop->set) { in stm32_fmc2_ebi_parse_prop()
936 dev_err(dev, "property %s is not well defined\n", prop->name); in stm32_fmc2_ebi_parse_prop()
937 return -EINVAL; in stm32_fmc2_ebi_parse_prop()
940 if (prop->check && prop->check(ebi, prop, cs)) in stm32_fmc2_ebi_parse_prop()
944 if (prop->bprop) { in stm32_fmc2_ebi_parse_prop()
947 bprop = of_property_read_bool(dev_node, prop->name); in stm32_fmc2_ebi_parse_prop()
948 if (prop->mprop && !bprop) { in stm32_fmc2_ebi_parse_prop()
950 prop->name); in stm32_fmc2_ebi_parse_prop()
951 return -EINVAL; in stm32_fmc2_ebi_parse_prop()
960 ret = of_property_read_u32(dev_node, prop->name, &val); in stm32_fmc2_ebi_parse_prop()
961 if (prop->mprop && ret) { in stm32_fmc2_ebi_parse_prop()
963 prop->name); in stm32_fmc2_ebi_parse_prop()
968 setup = prop->reset_val; in stm32_fmc2_ebi_parse_prop()
969 else if (prop->calculate) in stm32_fmc2_ebi_parse_prop()
970 setup = prop->calculate(ebi, cs, val); in stm32_fmc2_ebi_parse_prop()
975 return prop->set(ebi, prop, cs, setup); in stm32_fmc2_ebi_parse_prop()
978 static void stm32_fmc2_ebi_enable_bank(struct stm32_fmc2_ebi *ebi, int cs) in stm32_fmc2_ebi_enable_bank() argument
980 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), in stm32_fmc2_ebi_enable_bank()
984 static void stm32_fmc2_ebi_disable_bank(struct stm32_fmc2_ebi *ebi, int cs) in stm32_fmc2_ebi_disable_bank() argument
986 regmap_update_bits(ebi->regmap, FMC2_BCR(cs), FMC2_BCR_MBKEN, 0); in stm32_fmc2_ebi_disable_bank()
989 static int stm32_fmc2_ebi_save_setup(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_save_setup() argument
991 unsigned int cs; in stm32_fmc2_ebi_save_setup() local
994 for (cs = 0; cs < FMC2_MAX_EBI_CE; cs++) { in stm32_fmc2_ebi_save_setup()
995 ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &ebi->bcr[cs]); in stm32_fmc2_ebi_save_setup()
996 ret |= regmap_read(ebi->regmap, FMC2_BTR(cs), &ebi->btr[cs]); in stm32_fmc2_ebi_save_setup()
997 ret |= regmap_read(ebi->regmap, FMC2_BWTR(cs), &ebi->bwtr[cs]); in stm32_fmc2_ebi_save_setup()
1002 return regmap_read(ebi->regmap, FMC2_PCSCNTR, &ebi->pcscntr); in stm32_fmc2_ebi_save_setup()
1005 static void stm32_fmc2_ebi_set_setup(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_set_setup() argument
1007 unsigned int cs; in stm32_fmc2_ebi_set_setup() local
1009 for (cs = 0; cs < FMC2_MAX_EBI_CE; cs++) { in stm32_fmc2_ebi_set_setup()
1010 regmap_write(ebi->regmap, FMC2_BCR(cs), ebi->bcr[cs]); in stm32_fmc2_ebi_set_setup()
1011 regmap_write(ebi->regmap, FMC2_BTR(cs), ebi->btr[cs]); in stm32_fmc2_ebi_set_setup()
1012 regmap_write(ebi->regmap, FMC2_BWTR(cs), ebi->bwtr[cs]); in stm32_fmc2_ebi_set_setup()
1015 regmap_write(ebi->regmap, FMC2_PCSCNTR, ebi->pcscntr); in stm32_fmc2_ebi_set_setup()
1018 static void stm32_fmc2_ebi_disable_banks(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_disable_banks() argument
1020 unsigned int cs; in stm32_fmc2_ebi_disable_banks() local
1022 for (cs = 0; cs < FMC2_MAX_EBI_CE; cs++) { in stm32_fmc2_ebi_disable_banks()
1023 if (!(ebi->bank_assigned & BIT(cs))) in stm32_fmc2_ebi_disable_banks()
1026 stm32_fmc2_ebi_disable_bank(ebi, cs); in stm32_fmc2_ebi_disable_banks()
1030 /* NWAIT signal can not be connected to EBI controller and NAND controller */
1031 static int stm32_fmc2_ebi_nwait_used_by_ctrls(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_nwait_used_by_ctrls() argument
1033 struct device *dev = ebi->dev; in stm32_fmc2_ebi_nwait_used_by_ctrls()
1034 unsigned int cs; in stm32_fmc2_ebi_nwait_used_by_ctrls() local
1038 for (cs = 0; cs < FMC2_MAX_EBI_CE; cs++) { in stm32_fmc2_ebi_nwait_used_by_ctrls()
1039 if (!(ebi->bank_assigned & BIT(cs))) in stm32_fmc2_ebi_nwait_used_by_ctrls()
1042 ret = regmap_read(ebi->regmap, FMC2_BCR(cs), &bcr); in stm32_fmc2_ebi_nwait_used_by_ctrls()
1047 ebi->bank_assigned & BIT(FMC2_NAND)) { in stm32_fmc2_ebi_nwait_used_by_ctrls()
1048 dev_err(dev, "NWAIT signal connected to EBI and NAND controllers\n"); in stm32_fmc2_ebi_nwait_used_by_ctrls()
1049 return -EINVAL; in stm32_fmc2_ebi_nwait_used_by_ctrls()
1056 static void stm32_fmc2_ebi_enable(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_enable() argument
1058 regmap_update_bits(ebi->regmap, FMC2_BCR1, in stm32_fmc2_ebi_enable()
1062 static void stm32_fmc2_ebi_disable(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_disable() argument
1064 regmap_update_bits(ebi->regmap, FMC2_BCR1, FMC2_BCR1_FMC2EN, 0); in stm32_fmc2_ebi_disable()
1067 static int stm32_fmc2_ebi_setup_cs(struct stm32_fmc2_ebi *ebi, in stm32_fmc2_ebi_setup_cs() argument
1069 u32 cs) in stm32_fmc2_ebi_setup_cs() argument
1074 stm32_fmc2_ebi_disable_bank(ebi, cs); in stm32_fmc2_ebi_setup_cs()
1079 ret = stm32_fmc2_ebi_parse_prop(ebi, dev_node, p, cs); in stm32_fmc2_ebi_setup_cs()
1081 dev_err(ebi->dev, "property %s could not be set: %d\n", in stm32_fmc2_ebi_setup_cs()
1082 p->name, ret); in stm32_fmc2_ebi_setup_cs()
1087 stm32_fmc2_ebi_enable_bank(ebi, cs); in stm32_fmc2_ebi_setup_cs()
1092 static int stm32_fmc2_ebi_parse_dt(struct stm32_fmc2_ebi *ebi) in stm32_fmc2_ebi_parse_dt() argument
1094 struct device *dev = ebi->dev; in stm32_fmc2_ebi_parse_dt()
1100 for_each_available_child_of_node(dev->of_node, child) { in stm32_fmc2_ebi_parse_dt()
1112 return -EINVAL; in stm32_fmc2_ebi_parse_dt()
1115 if (ebi->bank_assigned & BIT(bank)) { in stm32_fmc2_ebi_parse_dt()
1118 return -EINVAL; in stm32_fmc2_ebi_parse_dt()
1122 ret = stm32_fmc2_ebi_setup_cs(ebi, child, bank); in stm32_fmc2_ebi_parse_dt()
1131 ebi->bank_assigned |= BIT(bank); in stm32_fmc2_ebi_parse_dt()
1137 return -ENODEV; in stm32_fmc2_ebi_parse_dt()
1140 ret = stm32_fmc2_ebi_nwait_used_by_ctrls(ebi); in stm32_fmc2_ebi_parse_dt()
1144 stm32_fmc2_ebi_enable(ebi); in stm32_fmc2_ebi_parse_dt()
1146 return of_platform_populate(dev->of_node, NULL, NULL, dev); in stm32_fmc2_ebi_parse_dt()
1151 struct device *dev = &pdev->dev; in stm32_fmc2_ebi_probe()
1152 struct stm32_fmc2_ebi *ebi; in stm32_fmc2_ebi_probe() local
1156 ebi = devm_kzalloc(&pdev->dev, sizeof(*ebi), GFP_KERNEL); in stm32_fmc2_ebi_probe()
1157 if (!ebi) in stm32_fmc2_ebi_probe()
1158 return -ENOMEM; in stm32_fmc2_ebi_probe()
1160 ebi->dev = dev; in stm32_fmc2_ebi_probe()
1162 ebi->regmap = device_node_to_regmap(dev->of_node); in stm32_fmc2_ebi_probe()
1163 if (IS_ERR(ebi->regmap)) in stm32_fmc2_ebi_probe()
1164 return PTR_ERR(ebi->regmap); in stm32_fmc2_ebi_probe()
1166 ebi->clk = devm_clk_get(dev, NULL); in stm32_fmc2_ebi_probe()
1167 if (IS_ERR(ebi->clk)) in stm32_fmc2_ebi_probe()
1168 return PTR_ERR(ebi->clk); in stm32_fmc2_ebi_probe()
1171 if (PTR_ERR(rstc) == -EPROBE_DEFER) in stm32_fmc2_ebi_probe()
1172 return -EPROBE_DEFER; in stm32_fmc2_ebi_probe()
1174 ret = clk_prepare_enable(ebi->clk); in stm32_fmc2_ebi_probe()
1183 ret = stm32_fmc2_ebi_parse_dt(ebi); in stm32_fmc2_ebi_probe()
1187 ret = stm32_fmc2_ebi_save_setup(ebi); in stm32_fmc2_ebi_probe()
1191 platform_set_drvdata(pdev, ebi); in stm32_fmc2_ebi_probe()
1196 stm32_fmc2_ebi_disable_banks(ebi); in stm32_fmc2_ebi_probe()
1197 stm32_fmc2_ebi_disable(ebi); in stm32_fmc2_ebi_probe()
1198 clk_disable_unprepare(ebi->clk); in stm32_fmc2_ebi_probe()
1205 struct stm32_fmc2_ebi *ebi = platform_get_drvdata(pdev); in stm32_fmc2_ebi_remove() local
1207 of_platform_depopulate(&pdev->dev); in stm32_fmc2_ebi_remove()
1208 stm32_fmc2_ebi_disable_banks(ebi); in stm32_fmc2_ebi_remove()
1209 stm32_fmc2_ebi_disable(ebi); in stm32_fmc2_ebi_remove()
1210 clk_disable_unprepare(ebi->clk); in stm32_fmc2_ebi_remove()
1217 struct stm32_fmc2_ebi *ebi = dev_get_drvdata(dev); in stm32_fmc2_ebi_suspend() local
1219 stm32_fmc2_ebi_disable(ebi); in stm32_fmc2_ebi_suspend()
1220 clk_disable_unprepare(ebi->clk); in stm32_fmc2_ebi_suspend()
1228 struct stm32_fmc2_ebi *ebi = dev_get_drvdata(dev); in stm32_fmc2_ebi_resume() local
1233 ret = clk_prepare_enable(ebi->clk); in stm32_fmc2_ebi_resume()
1237 stm32_fmc2_ebi_set_setup(ebi); in stm32_fmc2_ebi_resume()
1238 stm32_fmc2_ebi_enable(ebi); in stm32_fmc2_ebi_resume()
1247 {.compatible = "st,stm32mp1-fmc2-ebi"},
1265 MODULE_DESCRIPTION("STMicroelectronics STM32 FMC2 ebi driver");