Lines Matching refs:nmk_chip

41 void __nmk_gpio_set_slpm(struct nmk_gpio_chip *nmk_chip, unsigned int offset,  in __nmk_gpio_set_slpm()  argument
47 if (WARN_ON(nmk_chip->is_mobileye_soc)) in __nmk_gpio_set_slpm()
50 slpm = readl(nmk_chip->addr + NMK_GPIO_SLPC); in __nmk_gpio_set_slpm()
55 writel(slpm, nmk_chip->addr + NMK_GPIO_SLPC); in __nmk_gpio_set_slpm()
58 static void __nmk_gpio_set_output(struct nmk_gpio_chip *nmk_chip, in __nmk_gpio_set_output() argument
62 writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DATS); in __nmk_gpio_set_output()
64 writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DATC); in __nmk_gpio_set_output()
67 void __nmk_gpio_make_output(struct nmk_gpio_chip *nmk_chip, in __nmk_gpio_make_output() argument
70 writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DIRS); in __nmk_gpio_make_output()
71 __nmk_gpio_set_output(nmk_chip, offset, val); in __nmk_gpio_make_output()
79 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc); in nmk_gpio_irq_ack() local
81 clk_enable(nmk_chip->clk); in nmk_gpio_irq_ack()
82 writel(BIT(d->hwirq), nmk_chip->addr + NMK_GPIO_IC); in nmk_gpio_irq_ack()
83 clk_disable(nmk_chip->clk); in nmk_gpio_irq_ack()
91 static void __nmk_gpio_irq_modify(struct nmk_gpio_chip *nmk_chip, in __nmk_gpio_irq_modify() argument
103 rimscval = &nmk_chip->rimsc; in __nmk_gpio_irq_modify()
104 fimscval = &nmk_chip->fimsc; in __nmk_gpio_irq_modify()
107 if (WARN_ON(nmk_chip->is_mobileye_soc)) in __nmk_gpio_irq_modify()
111 rimscval = &nmk_chip->rwimsc; in __nmk_gpio_irq_modify()
112 fimscval = &nmk_chip->fwimsc; in __nmk_gpio_irq_modify()
116 if (nmk_chip->edge_rising & BIT(offset)) { in __nmk_gpio_irq_modify()
121 writel(*rimscval, nmk_chip->addr + rimscreg); in __nmk_gpio_irq_modify()
123 if (nmk_chip->edge_falling & BIT(offset)) { in __nmk_gpio_irq_modify()
128 writel(*fimscval, nmk_chip->addr + fimscreg); in __nmk_gpio_irq_modify()
132 static void __nmk_gpio_set_wake(struct nmk_gpio_chip *nmk_chip, in __nmk_gpio_set_wake() argument
136 if (WARN_ON(nmk_chip->is_mobileye_soc)) in __nmk_gpio_set_wake()
144 if (nmk_chip->sleepmode && on) { in __nmk_gpio_set_wake()
145 __nmk_gpio_set_slpm(nmk_chip, offset, in __nmk_gpio_set_wake()
149 __nmk_gpio_irq_modify(nmk_chip, offset, WAKE, on); in __nmk_gpio_set_wake()
152 static void nmk_gpio_irq_maskunmask(struct nmk_gpio_chip *nmk_chip, in nmk_gpio_irq_maskunmask() argument
157 clk_enable(nmk_chip->clk); in nmk_gpio_irq_maskunmask()
159 spin_lock(&nmk_chip->lock); in nmk_gpio_irq_maskunmask()
161 __nmk_gpio_irq_modify(nmk_chip, d->hwirq, NORMAL, enable); in nmk_gpio_irq_maskunmask()
163 if (!nmk_chip->is_mobileye_soc && !(nmk_chip->real_wake & BIT(d->hwirq))) in nmk_gpio_irq_maskunmask()
164 __nmk_gpio_set_wake(nmk_chip, d->hwirq, enable); in nmk_gpio_irq_maskunmask()
166 spin_unlock(&nmk_chip->lock); in nmk_gpio_irq_maskunmask()
168 clk_disable(nmk_chip->clk); in nmk_gpio_irq_maskunmask()
174 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc); in nmk_gpio_irq_mask() local
176 nmk_gpio_irq_maskunmask(nmk_chip, d, false); in nmk_gpio_irq_mask()
183 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc); in nmk_gpio_irq_unmask() local
186 nmk_gpio_irq_maskunmask(nmk_chip, d, true); in nmk_gpio_irq_unmask()
192 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc); in nmk_gpio_irq_set_wake() local
196 if (nmk_chip->is_mobileye_soc) in nmk_gpio_irq_set_wake()
199 clk_enable(nmk_chip->clk); in nmk_gpio_irq_set_wake()
201 spin_lock(&nmk_chip->lock); in nmk_gpio_irq_set_wake()
204 __nmk_gpio_set_wake(nmk_chip, d->hwirq, on); in nmk_gpio_irq_set_wake()
207 nmk_chip->real_wake |= BIT(d->hwirq); in nmk_gpio_irq_set_wake()
209 nmk_chip->real_wake &= ~BIT(d->hwirq); in nmk_gpio_irq_set_wake()
211 spin_unlock(&nmk_chip->lock); in nmk_gpio_irq_set_wake()
213 clk_disable(nmk_chip->clk); in nmk_gpio_irq_set_wake()
221 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc); in nmk_gpio_irq_set_type() local
231 clk_enable(nmk_chip->clk); in nmk_gpio_irq_set_type()
232 spin_lock_irqsave(&nmk_chip->lock, flags); in nmk_gpio_irq_set_type()
235 __nmk_gpio_irq_modify(nmk_chip, d->hwirq, NORMAL, false); in nmk_gpio_irq_set_type()
237 if (!nmk_chip->is_mobileye_soc && (enabled || wake)) in nmk_gpio_irq_set_type()
238 __nmk_gpio_irq_modify(nmk_chip, d->hwirq, WAKE, false); in nmk_gpio_irq_set_type()
240 nmk_chip->edge_rising &= ~BIT(d->hwirq); in nmk_gpio_irq_set_type()
242 nmk_chip->edge_rising |= BIT(d->hwirq); in nmk_gpio_irq_set_type()
244 nmk_chip->edge_falling &= ~BIT(d->hwirq); in nmk_gpio_irq_set_type()
246 nmk_chip->edge_falling |= BIT(d->hwirq); in nmk_gpio_irq_set_type()
249 __nmk_gpio_irq_modify(nmk_chip, d->hwirq, NORMAL, true); in nmk_gpio_irq_set_type()
251 if (!nmk_chip->is_mobileye_soc && (enabled || wake)) in nmk_gpio_irq_set_type()
252 __nmk_gpio_irq_modify(nmk_chip, d->hwirq, WAKE, true); in nmk_gpio_irq_set_type()
254 spin_unlock_irqrestore(&nmk_chip->lock, flags); in nmk_gpio_irq_set_type()
255 clk_disable(nmk_chip->clk); in nmk_gpio_irq_set_type()
263 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc); in nmk_gpio_irq_startup() local
265 clk_enable(nmk_chip->clk); in nmk_gpio_irq_startup()
273 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc); in nmk_gpio_irq_shutdown() local
276 clk_disable(nmk_chip->clk); in nmk_gpio_irq_shutdown()
281 struct nmk_gpio_chip *nmk_chip = dev_id; in nmk_gpio_irq_handler() local
282 struct gpio_chip *chip = &nmk_chip->chip; in nmk_gpio_irq_handler()
287 clk_enable(nmk_chip->clk); in nmk_gpio_irq_handler()
289 status = readl(nmk_chip->addr + NMK_GPIO_IS); in nmk_gpio_irq_handler()
293 writel(status & ~mask, nmk_chip->addr + NMK_GPIO_IC); in nmk_gpio_irq_handler()
295 clk_disable(nmk_chip->clk); in nmk_gpio_irq_handler()
307 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); in nmk_gpio_get_dir() local
310 clk_enable(nmk_chip->clk); in nmk_gpio_get_dir()
312 dir = readl(nmk_chip->addr + NMK_GPIO_DIR) & BIT(offset); in nmk_gpio_get_dir()
314 clk_disable(nmk_chip->clk); in nmk_gpio_get_dir()
324 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); in nmk_gpio_make_input() local
326 clk_enable(nmk_chip->clk); in nmk_gpio_make_input()
328 writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DIRC); in nmk_gpio_make_input()
330 clk_disable(nmk_chip->clk); in nmk_gpio_make_input()
337 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); in nmk_gpio_get_input() local
340 clk_enable(nmk_chip->clk); in nmk_gpio_get_input()
342 value = !!(readl(nmk_chip->addr + NMK_GPIO_DAT) & BIT(offset)); in nmk_gpio_get_input()
344 clk_disable(nmk_chip->clk); in nmk_gpio_get_input()
352 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); in nmk_gpio_set_output() local
354 clk_enable(nmk_chip->clk); in nmk_gpio_set_output()
356 __nmk_gpio_set_output(nmk_chip, offset, val); in nmk_gpio_set_output()
358 clk_disable(nmk_chip->clk); in nmk_gpio_set_output()
364 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); in nmk_gpio_make_output() local
366 clk_enable(nmk_chip->clk); in nmk_gpio_make_output()
368 __nmk_gpio_make_output(nmk_chip, offset, val); in nmk_gpio_make_output()
370 clk_disable(nmk_chip->clk); in nmk_gpio_make_output()
377 static int nmk_gpio_get_mode(struct nmk_gpio_chip *nmk_chip, int offset) in nmk_gpio_get_mode() argument
382 if (nmk_chip->is_mobileye_soc) in nmk_gpio_get_mode()
385 clk_enable(nmk_chip->clk); in nmk_gpio_get_mode()
387 afunc = readl(nmk_chip->addr + NMK_GPIO_AFSLA) & BIT(offset); in nmk_gpio_get_mode()
388 bfunc = readl(nmk_chip->addr + NMK_GPIO_AFSLB) & BIT(offset); in nmk_gpio_get_mode()
390 clk_disable(nmk_chip->clk); in nmk_gpio_get_mode()
399 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip); in nmk_gpio_dbg_show_one() local
419 clk_enable(nmk_chip->clk); in nmk_gpio_dbg_show_one()
420 is_out = !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & BIT(offset)); in nmk_gpio_dbg_show_one()
421 pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & BIT(offset)); in nmk_gpio_dbg_show_one()
422 data_out = !!(readl(nmk_chip->addr + NMK_GPIO_DAT) & BIT(offset)); in nmk_gpio_dbg_show_one()
423 mode = nmk_gpio_get_mode(nmk_chip, offset); in nmk_gpio_dbg_show_one()
461 if (nmk_chip->edge_rising & BIT(offset)) in nmk_gpio_dbg_show_one()
463 else if (nmk_chip->edge_falling & BIT(offset)) in nmk_gpio_dbg_show_one()
468 wake = !!(nmk_chip->real_wake & BIT(offset)); in nmk_gpio_dbg_show_one()
474 clk_disable(nmk_chip->clk); in nmk_gpio_dbg_show_one()
502 struct nmk_gpio_chip *nmk_chip; in nmk_gpio_populate_chip() local
534 nmk_chip = nmk_gpio_chips[id]; in nmk_gpio_populate_chip()
535 if (nmk_chip) { in nmk_gpio_populate_chip()
537 return nmk_chip; in nmk_gpio_populate_chip()
541 nmk_chip = devm_kzalloc(dev, sizeof(*nmk_chip), GFP_KERNEL); in nmk_gpio_populate_chip()
542 if (!nmk_chip) { in nmk_gpio_populate_chip()
552 nmk_chip->is_mobileye_soc = device_is_compatible(gpio_dev, in nmk_gpio_populate_chip()
554 nmk_chip->bank = id; in nmk_gpio_populate_chip()
555 chip = &nmk_chip->chip; in nmk_gpio_populate_chip()
568 nmk_chip->addr = base; in nmk_gpio_populate_chip()
577 nmk_chip->clk = clk; in nmk_gpio_populate_chip()
606 nmk_gpio_chips[id] = nmk_chip; in nmk_gpio_populate_chip()
608 return nmk_chip; in nmk_gpio_populate_chip()
614 struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(gc); in nmk_gpio_irq_print_chip() local
616 seq_printf(p, "nmk%u-%u-%u", nmk_chip->bank, in nmk_gpio_irq_print_chip()
636 struct nmk_gpio_chip *nmk_chip; in nmk_gpio_probe() local
643 nmk_chip = nmk_gpio_populate_chip(dev_fwnode(dev), pdev); in nmk_gpio_probe()
644 if (IS_ERR(nmk_chip)) { in nmk_gpio_probe()
646 return PTR_ERR(nmk_chip); in nmk_gpio_probe()
653 pdev->id = nmk_chip->bank; in nmk_gpio_probe()
663 nmk_chip->sleepmode = supports_sleepmode; in nmk_gpio_probe()
664 spin_lock_init(&nmk_chip->lock); in nmk_gpio_probe()
666 chip = &nmk_chip->chip; in nmk_gpio_probe()
688 dev_name(dev), nmk_chip); in nmk_gpio_probe()
694 if (!nmk_chip->is_mobileye_soc) { in nmk_gpio_probe()
695 clk_enable(nmk_chip->clk); in nmk_gpio_probe()
696 nmk_chip->lowemi = readl_relaxed(nmk_chip->addr + NMK_GPIO_LOWEMI); in nmk_gpio_probe()
697 clk_disable(nmk_chip->clk); in nmk_gpio_probe()
700 ret = gpiochip_add_data(chip, nmk_chip); in nmk_gpio_probe()
704 platform_set_drvdata(pdev, nmk_chip); in nmk_gpio_probe()