Laurent Pinchart | f916513 | 2012-12-15 23:50:44 +0100 | [diff] [blame] | 1 | /* |
| 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 Pinchart | bf9f067 | 2013-04-09 14:06:01 +0000 | [diff] [blame] | 14 | #include <linux/spinlock.h> |
Laurent Pinchart | f916513 | 2012-12-15 23:50:44 +0100 | [diff] [blame] | 15 | #include <linux/types.h> |
| 16 | |
Laurent Pinchart | c332380 | 2012-12-15 23:51:55 +0100 | [diff] [blame] | 17 | #include "sh_pfc.h" |
| 18 | |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 19 | struct sh_pfc_window { |
Laurent Pinchart | f916513 | 2012-12-15 23:50:44 +0100 | [diff] [blame] | 20 | phys_addr_t phys; |
| 21 | void __iomem *virt; |
| 22 | unsigned long size; |
| 23 | }; |
| 24 | |
Laurent Pinchart | 6f6a4a6 | 2012-12-15 23:50:46 +0100 | [diff] [blame] | 25 | struct sh_pfc_chip; |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 26 | struct sh_pfc_pinctrl; |
Laurent Pinchart | 6f6a4a6 | 2012-12-15 23:50:46 +0100 | [diff] [blame] | 27 | |
Laurent Pinchart | acac8ed | 2013-07-15 18:38:30 +0200 | [diff] [blame] | 28 | struct sh_pfc_pin_range { |
| 29 | u16 start; |
| 30 | u16 end; |
| 31 | }; |
| 32 | |
Laurent Pinchart | f916513 | 2012-12-15 23:50:44 +0100 | [diff] [blame] | 33 | struct sh_pfc { |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 34 | struct device *dev; |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 35 | const struct sh_pfc_soc_info *info; |
Laurent Pinchart | f916513 | 2012-12-15 23:50:44 +0100 | [diff] [blame] | 36 | spinlock_t lock; |
| 37 | |
Laurent Pinchart | 973931a | 2012-12-15 23:50:55 +0100 | [diff] [blame] | 38 | unsigned int num_windows; |
Laurent Pinchart | 5b46ac3 | 2013-12-11 04:26:25 +0100 | [diff] [blame] | 39 | struct sh_pfc_window *windows; |
Laurent Pinchart | 70c8f01 | 2013-12-11 04:26:26 +0100 | [diff] [blame] | 40 | unsigned int num_irqs; |
| 41 | unsigned int *irqs; |
Laurent Pinchart | 973931a | 2012-12-15 23:50:55 +0100 | [diff] [blame] | 42 | |
Laurent Pinchart | acac8ed | 2013-07-15 18:38:30 +0200 | [diff] [blame] | 43 | struct sh_pfc_pin_range *ranges; |
| 44 | unsigned int nr_ranges; |
| 45 | |
Laurent Pinchart | 28818fa | 2013-07-15 13:48:56 +0200 | [diff] [blame] | 46 | unsigned int nr_gpio_pins; |
Laurent Pinchart | 63d5738 | 2013-02-15 01:33:38 +0100 | [diff] [blame] | 47 | |
Laurent Pinchart | 6f6a4a6 | 2012-12-15 23:50:46 +0100 | [diff] [blame] | 48 | struct sh_pfc_chip *gpio; |
Laurent Pinchart | 1688381 | 2012-12-06 14:49:25 +0100 | [diff] [blame] | 49 | struct sh_pfc_chip *func; |
| 50 | |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 51 | struct sh_pfc_pinctrl *pinctrl; |
Laurent Pinchart | f916513 | 2012-12-15 23:50:44 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | int sh_pfc_register_gpiochip(struct sh_pfc *pfc); |
Laurent Pinchart | 6f6a4a6 | 2012-12-15 23:50:46 +0100 | [diff] [blame] | 55 | int sh_pfc_unregister_gpiochip(struct sh_pfc *pfc); |
Laurent Pinchart | f916513 | 2012-12-15 23:50:44 +0100 | [diff] [blame] | 56 | |
| 57 | int sh_pfc_register_pinctrl(struct sh_pfc *pfc); |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 58 | int sh_pfc_unregister_pinctrl(struct sh_pfc *pfc); |
Laurent Pinchart | f916513 | 2012-12-15 23:50:44 +0100 | [diff] [blame] | 59 | |
Laurent Pinchart | 41f1219 | 2013-02-15 02:04:55 +0100 | [diff] [blame] | 60 | unsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg, |
| 61 | unsigned long reg_width); |
| 62 | void sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned long reg_width, |
| 63 | unsigned long data); |
| 64 | |
Laurent Pinchart | 1a0039d | 2013-03-08 17:43:54 +0100 | [diff] [blame] | 65 | int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin); |
Laurent Pinchart | 861601d | 2013-03-10 15:29:14 +0100 | [diff] [blame] | 66 | int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type); |
Laurent Pinchart | f916513 | 2012-12-15 23:50:44 +0100 | [diff] [blame] | 67 | |
Magnus Damm | c98f6c2 | 2013-03-26 22:49:49 +0900 | [diff] [blame] | 68 | extern const struct sh_pfc_soc_info r8a73a4_pinmux_info; |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 69 | extern const struct sh_pfc_soc_info r8a7740_pinmux_info; |
Kuninori Morimoto | 87f8c98 | 2013-04-12 05:37:20 +0000 | [diff] [blame] | 70 | extern const struct sh_pfc_soc_info r8a7778_pinmux_info; |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 71 | extern const struct sh_pfc_soc_info r8a7779_pinmux_info; |
Koji Matsuoka | 58c229e | 2013-04-08 11:08:53 +0900 | [diff] [blame] | 72 | extern const struct sh_pfc_soc_info r8a7790_pinmux_info; |
Hisashi Nakamura | 5088451 | 2013-10-17 06:46:05 +0900 | [diff] [blame] | 73 | extern const struct sh_pfc_soc_info r8a7791_pinmux_info; |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 74 | extern const struct sh_pfc_soc_info sh7203_pinmux_info; |
| 75 | extern const struct sh_pfc_soc_info sh7264_pinmux_info; |
| 76 | extern const struct sh_pfc_soc_info sh7269_pinmux_info; |
| 77 | extern const struct sh_pfc_soc_info sh7372_pinmux_info; |
| 78 | extern const struct sh_pfc_soc_info sh73a0_pinmux_info; |
| 79 | extern const struct sh_pfc_soc_info sh7720_pinmux_info; |
| 80 | extern const struct sh_pfc_soc_info sh7722_pinmux_info; |
| 81 | extern const struct sh_pfc_soc_info sh7723_pinmux_info; |
| 82 | extern const struct sh_pfc_soc_info sh7724_pinmux_info; |
| 83 | extern const struct sh_pfc_soc_info sh7734_pinmux_info; |
| 84 | extern const struct sh_pfc_soc_info sh7757_pinmux_info; |
| 85 | extern const struct sh_pfc_soc_info sh7785_pinmux_info; |
| 86 | extern const struct sh_pfc_soc_info sh7786_pinmux_info; |
| 87 | extern const struct sh_pfc_soc_info shx3_pinmux_info; |
Laurent Pinchart | d5b1521 | 2012-12-15 23:51:21 +0100 | [diff] [blame] | 88 | |
Laurent Pinchart | f916513 | 2012-12-15 23:50:44 +0100 | [diff] [blame] | 89 | #endif /* __SH_PFC_CORE_H__ */ |