blob: 8a10dd50ccdd2e0c7f490d62ead0bf7246c37696 [file] [log] [blame]
Laurent Pinchartf9165132012-12-15 23:50:44 +01001/*
2 * SuperH Pin Function Controller support.
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef __SH_PFC_CORE_H__
11#define __SH_PFC_CORE_H__
12
13#include <linux/compiler.h>
Laurent Pinchartbf9f0672013-04-09 14:06:01 +000014#include <linux/spinlock.h>
Laurent Pinchartf9165132012-12-15 23:50:44 +010015#include <linux/types.h>
16
Laurent Pinchartc3323802012-12-15 23:51:55 +010017#include "sh_pfc.h"
18
Laurent Pinchart4aeacd52012-12-15 23:50:53 +010019struct sh_pfc_window {
Laurent Pinchartf9165132012-12-15 23:50:44 +010020 phys_addr_t phys;
21 void __iomem *virt;
22 unsigned long size;
23};
24
Laurent Pinchart6f6a4a62012-12-15 23:50:46 +010025struct sh_pfc_chip;
Laurent Pinchartc6193ea2012-12-15 23:50:47 +010026struct sh_pfc_pinctrl;
Laurent Pinchart6f6a4a62012-12-15 23:50:46 +010027
Laurent Pinchartacac8ed2013-07-15 18:38:30 +020028struct sh_pfc_pin_range {
29 u16 start;
30 u16 end;
31};
32
Laurent Pinchartf9165132012-12-15 23:50:44 +010033struct sh_pfc {
Laurent Pinchartc6193ea2012-12-15 23:50:47 +010034 struct device *dev;
Laurent Pinchartcd3c1be2013-02-16 18:47:05 +010035 const struct sh_pfc_soc_info *info;
Laurent Pinchartf9165132012-12-15 23:50:44 +010036 spinlock_t lock;
37
Laurent Pinchart973931a2012-12-15 23:50:55 +010038 unsigned int num_windows;
Laurent Pinchart5b46ac32013-12-11 04:26:25 +010039 struct sh_pfc_window *windows;
Laurent Pinchart70c8f012013-12-11 04:26:26 +010040 unsigned int num_irqs;
41 unsigned int *irqs;
Laurent Pinchart973931a2012-12-15 23:50:55 +010042
Laurent Pinchartacac8ed2013-07-15 18:38:30 +020043 struct sh_pfc_pin_range *ranges;
44 unsigned int nr_ranges;
45
Laurent Pinchart28818fa2013-07-15 13:48:56 +020046 unsigned int nr_gpio_pins;
Laurent Pinchart63d57382013-02-15 01:33:38 +010047
Laurent Pinchart6f6a4a62012-12-15 23:50:46 +010048 struct sh_pfc_chip *gpio;
Laurent Pinchart16883812012-12-06 14:49:25 +010049 struct sh_pfc_chip *func;
50
Laurent Pinchartc6193ea2012-12-15 23:50:47 +010051 struct sh_pfc_pinctrl *pinctrl;
Laurent Pinchartf9165132012-12-15 23:50:44 +010052};
53
54int sh_pfc_register_gpiochip(struct sh_pfc *pfc);
Laurent Pinchart6f6a4a62012-12-15 23:50:46 +010055int sh_pfc_unregister_gpiochip(struct sh_pfc *pfc);
Laurent Pinchartf9165132012-12-15 23:50:44 +010056
57int sh_pfc_register_pinctrl(struct sh_pfc *pfc);
Laurent Pinchartc6193ea2012-12-15 23:50:47 +010058int sh_pfc_unregister_pinctrl(struct sh_pfc *pfc);
Laurent Pinchartf9165132012-12-15 23:50:44 +010059
Geert Uytterhoevenfc889362015-02-27 18:38:04 +010060u32 sh_pfc_read_raw_reg(void __iomem *mapped_reg, unsigned long reg_width);
Laurent Pinchart41f12192013-02-15 02:04:55 +010061void sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned long reg_width,
Geert Uytterhoevenfc889362015-02-27 18:38:04 +010062 u32 data);
Laurent Pinchart41f12192013-02-15 02:04:55 +010063
Laurent Pinchart1a0039d2013-03-08 17:43:54 +010064int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin);
Laurent Pinchart861601d2013-03-10 15:29:14 +010065int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type);
Laurent Pinchartf9165132012-12-15 23:50:44 +010066
Niklas Söderlund1e7d5d82015-01-25 14:49:52 +010067extern const struct sh_pfc_soc_info emev2_pinmux_info;
Magnus Dammc98f6c22013-03-26 22:49:49 +090068extern const struct sh_pfc_soc_info r8a73a4_pinmux_info;
Laurent Pinchartcd3c1be2013-02-16 18:47:05 +010069extern const struct sh_pfc_soc_info r8a7740_pinmux_info;
Kuninori Morimoto87f8c982013-04-12 05:37:20 +000070extern const struct sh_pfc_soc_info r8a7778_pinmux_info;
Laurent Pinchartcd3c1be2013-02-16 18:47:05 +010071extern const struct sh_pfc_soc_info r8a7779_pinmux_info;
Koji Matsuoka58c229e2013-04-08 11:08:53 +090072extern const struct sh_pfc_soc_info r8a7790_pinmux_info;
Hisashi Nakamura50884512013-10-17 06:46:05 +090073extern const struct sh_pfc_soc_info r8a7791_pinmux_info;
Laurent Pinchartcd3c1be2013-02-16 18:47:05 +010074extern const struct sh_pfc_soc_info sh7203_pinmux_info;
75extern const struct sh_pfc_soc_info sh7264_pinmux_info;
76extern const struct sh_pfc_soc_info sh7269_pinmux_info;
Laurent Pinchartcd3c1be2013-02-16 18:47:05 +010077extern const struct sh_pfc_soc_info sh73a0_pinmux_info;
78extern const struct sh_pfc_soc_info sh7720_pinmux_info;
79extern const struct sh_pfc_soc_info sh7722_pinmux_info;
80extern const struct sh_pfc_soc_info sh7723_pinmux_info;
81extern const struct sh_pfc_soc_info sh7724_pinmux_info;
82extern const struct sh_pfc_soc_info sh7734_pinmux_info;
83extern const struct sh_pfc_soc_info sh7757_pinmux_info;
84extern const struct sh_pfc_soc_info sh7785_pinmux_info;
85extern const struct sh_pfc_soc_info sh7786_pinmux_info;
86extern const struct sh_pfc_soc_info shx3_pinmux_info;
Laurent Pinchartd5b15212012-12-15 23:51:21 +010087
Laurent Pinchartf9165132012-12-15 23:50:44 +010088#endif /* __SH_PFC_CORE_H__ */