blob: a1b23762ac90691063d7aea5d14758c162bceaf5 [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 Pinchart0c151062013-04-21 20:21:57 +020036 void *soc_data;
Laurent Pinchartf9165132012-12-15 23:50:44 +010037 spinlock_t lock;
38
Laurent Pinchart973931a2012-12-15 23:50:55 +010039 unsigned int num_windows;
Laurent Pinchart4aeacd52012-12-15 23:50:53 +010040 struct sh_pfc_window *window;
Laurent Pinchart973931a2012-12-15 23:50:55 +010041
Laurent Pinchartacac8ed2013-07-15 18:38:30 +020042 struct sh_pfc_pin_range *ranges;
43 unsigned int nr_ranges;
44
Laurent Pinchart28818fa2013-07-15 13:48:56 +020045 unsigned int nr_gpio_pins;
Laurent Pinchart63d57382013-02-15 01:33:38 +010046
Laurent Pinchart6f6a4a62012-12-15 23:50:46 +010047 struct sh_pfc_chip *gpio;
Laurent Pinchart16883812012-12-06 14:49:25 +010048 struct sh_pfc_chip *func;
49
Laurent Pinchartc6193ea2012-12-15 23:50:47 +010050 struct sh_pfc_pinctrl *pinctrl;
Laurent Pinchartf9165132012-12-15 23:50:44 +010051};
52
53int sh_pfc_register_gpiochip(struct sh_pfc *pfc);
Laurent Pinchart6f6a4a62012-12-15 23:50:46 +010054int sh_pfc_unregister_gpiochip(struct sh_pfc *pfc);
Laurent Pinchartf9165132012-12-15 23:50:44 +010055
56int sh_pfc_register_pinctrl(struct sh_pfc *pfc);
Laurent Pinchartc6193ea2012-12-15 23:50:47 +010057int sh_pfc_unregister_pinctrl(struct sh_pfc *pfc);
Laurent Pinchartf9165132012-12-15 23:50:44 +010058
Laurent Pinchart41f12192013-02-15 02:04:55 +010059unsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg,
60 unsigned long reg_width);
61void sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned long reg_width,
62 unsigned long data);
63
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
Magnus Dammc98f6c22013-03-26 22:49:49 +090067extern const struct sh_pfc_soc_info r8a73a4_pinmux_info;
Laurent Pinchartcd3c1be2013-02-16 18:47:05 +010068extern const struct sh_pfc_soc_info r8a7740_pinmux_info;
Kuninori Morimoto87f8c982013-04-12 05:37:20 +000069extern const struct sh_pfc_soc_info r8a7778_pinmux_info;
Laurent Pinchartcd3c1be2013-02-16 18:47:05 +010070extern const struct sh_pfc_soc_info r8a7779_pinmux_info;
Koji Matsuoka58c229e2013-04-08 11:08:53 +090071extern const struct sh_pfc_soc_info r8a7790_pinmux_info;
Laurent Pinchartcd3c1be2013-02-16 18:47:05 +010072extern const struct sh_pfc_soc_info sh7203_pinmux_info;
73extern const struct sh_pfc_soc_info sh7264_pinmux_info;
74extern const struct sh_pfc_soc_info sh7269_pinmux_info;
75extern const struct sh_pfc_soc_info sh7372_pinmux_info;
76extern const struct sh_pfc_soc_info sh73a0_pinmux_info;
77extern const struct sh_pfc_soc_info sh7720_pinmux_info;
78extern const struct sh_pfc_soc_info sh7722_pinmux_info;
79extern const struct sh_pfc_soc_info sh7723_pinmux_info;
80extern const struct sh_pfc_soc_info sh7724_pinmux_info;
81extern const struct sh_pfc_soc_info sh7734_pinmux_info;
82extern const struct sh_pfc_soc_info sh7757_pinmux_info;
83extern const struct sh_pfc_soc_info sh7785_pinmux_info;
84extern const struct sh_pfc_soc_info sh7786_pinmux_info;
85extern const struct sh_pfc_soc_info shx3_pinmux_info;
Laurent Pinchartd5b15212012-12-15 23:51:21 +010086
Laurent Pinchartf9165132012-12-15 23:50:44 +010087#endif /* __SH_PFC_CORE_H__ */