[go: nahoru, domu]

1f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart/*
2f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart * SuperH Pin Function Controller support.
3f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart *
4f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart * Copyright (C) 2012  Renesas Solutions Corp.
5f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart *
6f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart * This file is subject to the terms and conditions of the GNU General Public
7f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart * License.  See the file "COPYING" in the main directory of this archive
8f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart * for more details.
9f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart */
10f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart#ifndef __SH_PFC_CORE_H__
11f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart#define __SH_PFC_CORE_H__
12f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart
13f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart#include <linux/compiler.h>
14bf9f0674e39ee2070d39c2bd2febef42c31b3fc0Laurent Pinchart#include <linux/spinlock.h>
15f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart#include <linux/types.h>
16f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart
17c3323806a67c0c656e27956b7340e37ba6c6968bLaurent Pinchart#include "sh_pfc.h"
18c3323806a67c0c656e27956b7340e37ba6c6968bLaurent Pinchart
194aeacd5bd5c354c1b36bfe3d5d72806ecd9605a0Laurent Pinchartstruct sh_pfc_window {
20f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart	phys_addr_t phys;
21f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart	void __iomem *virt;
22f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart	unsigned long size;
23f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart};
24f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart
256f6a4a683be97837f3baae443aacd2b0e6162b10Laurent Pinchartstruct sh_pfc_chip;
26c6193eacda6d50c405b0d484f5f2577ff9068a13Laurent Pinchartstruct sh_pfc_pinctrl;
276f6a4a683be97837f3baae443aacd2b0e6162b10Laurent Pinchart
28acac8ed5e2aa2c0d364d06f364fd9ed0dc27d28aLaurent Pinchartstruct sh_pfc_pin_range {
29acac8ed5e2aa2c0d364d06f364fd9ed0dc27d28aLaurent Pinchart	u16 start;
30acac8ed5e2aa2c0d364d06f364fd9ed0dc27d28aLaurent Pinchart	u16 end;
31acac8ed5e2aa2c0d364d06f364fd9ed0dc27d28aLaurent Pinchart};
32acac8ed5e2aa2c0d364d06f364fd9ed0dc27d28aLaurent Pinchart
33f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchartstruct sh_pfc {
34c6193eacda6d50c405b0d484f5f2577ff9068a13Laurent Pinchart	struct device *dev;
35cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchart	const struct sh_pfc_soc_info *info;
36f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart	spinlock_t lock;
37f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart
38973931ae0a2dad57e23ce0ca2fab5abed9cf0d9aLaurent Pinchart	unsigned int num_windows;
395b46ac3a7723636082ec6234289517ca5b9c65afLaurent Pinchart	struct sh_pfc_window *windows;
4070c8f01a357ac74d223a632659787396fef1e649Laurent Pinchart	unsigned int num_irqs;
4170c8f01a357ac74d223a632659787396fef1e649Laurent Pinchart	unsigned int *irqs;
42973931ae0a2dad57e23ce0ca2fab5abed9cf0d9aLaurent Pinchart
43acac8ed5e2aa2c0d364d06f364fd9ed0dc27d28aLaurent Pinchart	struct sh_pfc_pin_range *ranges;
44acac8ed5e2aa2c0d364d06f364fd9ed0dc27d28aLaurent Pinchart	unsigned int nr_ranges;
45acac8ed5e2aa2c0d364d06f364fd9ed0dc27d28aLaurent Pinchart
4628818fa5dadfd458fa7e17c8be26b2d7edffa8bfLaurent Pinchart	unsigned int nr_gpio_pins;
4763d573835f835aab4c44d0e0342cf5976fb14b35Laurent Pinchart
486f6a4a683be97837f3baae443aacd2b0e6162b10Laurent Pinchart	struct sh_pfc_chip *gpio;
4916883814eca229506cd2a4e447b2b5a2338fa35eLaurent Pinchart	struct sh_pfc_chip *func;
5016883814eca229506cd2a4e447b2b5a2338fa35eLaurent Pinchart
51c6193eacda6d50c405b0d484f5f2577ff9068a13Laurent Pinchart	struct sh_pfc_pinctrl *pinctrl;
52f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart};
53f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart
54f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchartint sh_pfc_register_gpiochip(struct sh_pfc *pfc);
556f6a4a683be97837f3baae443aacd2b0e6162b10Laurent Pinchartint sh_pfc_unregister_gpiochip(struct sh_pfc *pfc);
56f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart
57f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchartint sh_pfc_register_pinctrl(struct sh_pfc *pfc);
58c6193eacda6d50c405b0d484f5f2577ff9068a13Laurent Pinchartint sh_pfc_unregister_pinctrl(struct sh_pfc *pfc);
59f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart
6041f1219fae987f97787677d3a91c2f33ca9bab98Laurent Pinchartunsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg,
6141f1219fae987f97787677d3a91c2f33ca9bab98Laurent Pinchart				  unsigned long reg_width);
6241f1219fae987f97787677d3a91c2f33ca9bab98Laurent Pinchartvoid sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned long reg_width,
6341f1219fae987f97787677d3a91c2f33ca9bab98Laurent Pinchart			  unsigned long data);
6441f1219fae987f97787677d3a91c2f33ca9bab98Laurent Pinchart
651a0039dce269317a843d4fc85c4a3430b484bc2dLaurent Pinchartint sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin);
66861601de101215494e2cc7918e8633d63da490efLaurent Pinchartint sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type);
67f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart
68c98f6c21afaf4692886cea0f5b63ead9945d85ccMagnus Dammextern const struct sh_pfc_soc_info r8a73a4_pinmux_info;
69cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info r8a7740_pinmux_info;
7087f8c988636db0d477bb63fddfaefb5be9b1c386Kuninori Morimotoextern const struct sh_pfc_soc_info r8a7778_pinmux_info;
71cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info r8a7779_pinmux_info;
7258c229e18b7754dfe505f3bc1688feb28c84f42aKoji Matsuokaextern const struct sh_pfc_soc_info r8a7790_pinmux_info;
735088451962389924b9f05e22e6956f5c1a515d1aHisashi Nakamuraextern const struct sh_pfc_soc_info r8a7791_pinmux_info;
74cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7203_pinmux_info;
75cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7264_pinmux_info;
76cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7269_pinmux_info;
77cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7372_pinmux_info;
78cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh73a0_pinmux_info;
79cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7720_pinmux_info;
80cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7722_pinmux_info;
81cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7723_pinmux_info;
82cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7724_pinmux_info;
83cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7734_pinmux_info;
84cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7757_pinmux_info;
85cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7785_pinmux_info;
86cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info sh7786_pinmux_info;
87cd3c1beecfeb757b16904386ea474d3c272de4eeLaurent Pinchartextern const struct sh_pfc_soc_info shx3_pinmux_info;
88d5b1521a94659167e77616368fe6e7c9b3aa1733Laurent Pinchart
89f9165132c5ee681235068857e4f86c7ecc5a4617Laurent Pinchart#endif /* __SH_PFC_CORE_H__ */
90