~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-omap2/mux.h

Version: ~ [ linux-5.6-rc1 ] ~ [ linux-5.5.2 ] ~ [ linux-5.4.17 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.102 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.170 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.213 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.213 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2009 Nokia
  3  * Copyright (C) 2009-2010 Texas Instruments
  4  *
  5  * This program is free software; you can redistribute it and/or modify
  6  * it under the terms of the GNU General Public License version 2 as
  7  * published by the Free Software Foundation.
  8  */
  9 
 10 #include "mux2420.h"
 11 #include "mux2430.h"
 12 #include "mux34xx.h"
 13 
 14 #define OMAP_MUX_TERMINATOR     0xffff
 15 
 16 /* 34xx mux mode options for each pin. See TRM for options */
 17 #define OMAP_MUX_MODE0      0
 18 #define OMAP_MUX_MODE1      1
 19 #define OMAP_MUX_MODE2      2
 20 #define OMAP_MUX_MODE3      3
 21 #define OMAP_MUX_MODE4      4
 22 #define OMAP_MUX_MODE5      5
 23 #define OMAP_MUX_MODE6      6
 24 #define OMAP_MUX_MODE7      7
 25 
 26 /* 24xx/34xx mux bit defines */
 27 #define OMAP_PULL_ENA                   (1 << 3)
 28 #define OMAP_PULL_UP                    (1 << 4)
 29 #define OMAP_ALTELECTRICALSEL           (1 << 5)
 30 
 31 /* 34xx specific mux bit defines */
 32 #define OMAP_INPUT_EN                   (1 << 8)
 33 #define OMAP_OFF_EN                     (1 << 9)
 34 #define OMAP_OFFOUT_EN                  (1 << 10)
 35 #define OMAP_OFFOUT_VAL                 (1 << 11)
 36 #define OMAP_OFF_PULL_EN                (1 << 12)
 37 #define OMAP_OFF_PULL_UP                (1 << 13)
 38 #define OMAP_WAKEUP_EN                  (1 << 14)
 39 
 40 /* 44xx specific mux bit defines */
 41 #define OMAP_WAKEUP_EVENT               (1 << 15)
 42 
 43 /* Active pin states */
 44 #define OMAP_PIN_OUTPUT                 0
 45 #define OMAP_PIN_INPUT                  OMAP_INPUT_EN
 46 #define OMAP_PIN_INPUT_PULLUP           (OMAP_PULL_ENA | OMAP_INPUT_EN \
 47                                                 | OMAP_PULL_UP)
 48 #define OMAP_PIN_INPUT_PULLDOWN         (OMAP_PULL_ENA | OMAP_INPUT_EN)
 49 
 50 /* Off mode states */
 51 #define OMAP_PIN_OFF_NONE               0
 52 #define OMAP_PIN_OFF_OUTPUT_HIGH        (OMAP_OFF_EN | OMAP_OFFOUT_EN \
 53                                                 | OMAP_OFFOUT_VAL)
 54 #define OMAP_PIN_OFF_OUTPUT_LOW         (OMAP_OFF_EN | OMAP_OFFOUT_EN)
 55 #define OMAP_PIN_OFF_INPUT_PULLUP       (OMAP_OFF_EN | OMAP_OFF_PULL_EN \
 56                                                 | OMAP_OFF_PULL_UP)
 57 #define OMAP_PIN_OFF_INPUT_PULLDOWN     (OMAP_OFF_EN | OMAP_OFF_PULL_EN)
 58 #define OMAP_PIN_OFF_WAKEUPENABLE       OMAP_WAKEUP_EN
 59 
 60 #define OMAP_MODE_GPIO(partition, x)    (((x) & OMAP_MUX_MODE7) == \
 61                                           partition->gpio)
 62 #define OMAP_MODE_UART(x)       (((x) & OMAP_MUX_MODE7) == OMAP_MUX_MODE0)
 63 
 64 /* Flags for omapX_mux_init */
 65 #define OMAP_PACKAGE_MASK               0xffff
 66 #define OMAP_PACKAGE_CBP                6               /* 515-pin 0.40 0.50 */
 67 #define OMAP_PACKAGE_CUS                5               /* 423-pin 0.65 */
 68 #define OMAP_PACKAGE_CBB                4               /* 515-pin 0.40 0.50 */
 69 #define OMAP_PACKAGE_CBC                3               /* 515-pin 0.50 0.65 */
 70 #define OMAP_PACKAGE_ZAC                2               /* 24xx 447-pin POP */
 71 #define OMAP_PACKAGE_ZAF                1               /* 2420 447-pin SIP */
 72 
 73 
 74 #define OMAP_MUX_NR_MODES               8               /* Available modes */
 75 #define OMAP_MUX_NR_SIDES               2               /* Bottom & top */
 76 
 77 /*
 78  * omap_mux_init flags definition:
 79  *
 80  * OMAP_GPIO_MUX_MODE, bits 0-2: gpio muxing mode, same like pad control
 81  *      register which includes values from 0-7.
 82  * OMAP_MUX_REG_8BIT: Ensure that access to padconf is done in 8 bits.
 83  * The default value is 16 bits.
 84  */
 85 #define OMAP_MUX_GPIO_IN_MODE0          OMAP_MUX_MODE0
 86 #define OMAP_MUX_GPIO_IN_MODE1          OMAP_MUX_MODE1
 87 #define OMAP_MUX_GPIO_IN_MODE2          OMAP_MUX_MODE2
 88 #define OMAP_MUX_GPIO_IN_MODE3          OMAP_MUX_MODE3
 89 #define OMAP_MUX_GPIO_IN_MODE4          OMAP_MUX_MODE4
 90 #define OMAP_MUX_GPIO_IN_MODE5          OMAP_MUX_MODE5
 91 #define OMAP_MUX_GPIO_IN_MODE6          OMAP_MUX_MODE6
 92 #define OMAP_MUX_GPIO_IN_MODE7          OMAP_MUX_MODE7
 93 #define OMAP_MUX_REG_8BIT               (1 << 3)
 94 
 95 /**
 96  * struct omap_board_data - board specific device data
 97  * @id: instance id
 98  * @flags: additional flags for platform init code
 99  * @pads: array of device specific pads
100  * @pads_cnt: ARRAY_SIZE() of pads
101  */
102 struct omap_board_data {
103         int                     id;
104         u32                     flags;
105         struct omap_device_pad  *pads;
106         int                     pads_cnt;
107 };
108 
109 /**
110  * struct mux_partition - contain partition related information
111  * @name: name of the current partition
112  * @flags: flags specific to this partition
113  * @gpio: gpio mux mode
114  * @phys: physical address
115  * @size: partition size
116  * @base: virtual address after ioremap
117  * @muxmodes: list of nodes that belong to a partition
118  * @node: list node for the partitions linked list
119  */
120 struct omap_mux_partition {
121         const char              *name;
122         u32                     flags;
123         u32                     gpio;
124         u32                     phys;
125         u32                     size;
126         void __iomem            *base;
127         struct list_head        muxmodes;
128         struct list_head        node;
129 };
130 
131 /**
132  * struct omap_mux - data for omap mux register offset and it's value
133  * @reg_offset: mux register offset from the mux base
134  * @gpio:       GPIO number
135  * @muxnames:   available signal modes for a ball
136  * @balls:      available balls on the package
137  */
138 struct omap_mux {
139         u16     reg_offset;
140         u16     gpio;
141 #ifdef CONFIG_OMAP_MUX
142         char    *muxnames[OMAP_MUX_NR_MODES];
143 #ifdef CONFIG_DEBUG_FS
144         char    *balls[OMAP_MUX_NR_SIDES];
145 #endif
146 #endif
147 };
148 
149 /**
150  * struct omap_ball - data for balls on omap package
151  * @reg_offset: mux register offset from the mux base
152  * @balls:      available balls on the package
153  */
154 struct omap_ball {
155         u16     reg_offset;
156         char    *balls[OMAP_MUX_NR_SIDES];
157 };
158 
159 /**
160  * struct omap_board_mux - data for initializing mux registers
161  * @reg_offset: mux register offset from the mux base
162  * @mux_value:  desired mux value to set
163  */
164 struct omap_board_mux {
165         u16     reg_offset;
166         u16     value;
167 };
168 
169 #define OMAP_DEVICE_PAD_REMUX           BIT(1)  /* Dynamically remux a pad,
170                                                    needs enable, idle and off
171                                                    values */
172 #define OMAP_DEVICE_PAD_WAKEUP          BIT(0)  /* Pad is wake-up capable */
173 
174 /**
175  * struct omap_device_pad - device specific pad configuration
176  * @name:               signal name
177  * @flags:              pad specific runtime flags
178  * @enable:             runtime value for a pad
179  * @idle:               idle value for a pad
180  * @off:                off value for a pad, defaults to safe mode
181  * @partition:          mux partition
182  * @mux:                mux register
183  */
184 struct omap_device_pad {
185         char                            *name;
186         u8                              flags;
187         u16                             enable;
188         u16                             idle;
189         u16                             off;
190         struct omap_mux_partition       *partition;
191         struct omap_mux                 *mux;
192 };
193 
194 struct omap_hwmod_mux_info;
195 
196 #define OMAP_MUX_STATIC(signal, mode)                                   \
197 {                                                                       \
198         .name   = (signal),                                             \
199         .enable = (mode),                                               \
200 }
201 
202 #if defined(CONFIG_OMAP_MUX)
203 
204 /**
205  * omap_mux_init_gpio - initialize a signal based on the GPIO number
206  * @gpio:               GPIO number
207  * @val:                Options for the mux register value
208  */
209 int omap_mux_init_gpio(int gpio, int val);
210 
211 /**
212  * omap_mux_init_signal - initialize a signal based on the signal name
213  * @muxname:            Mux name in mode0_name.signal_name format
214  * @val:                Options for the mux register value
215  */
216 int omap_mux_init_signal(const char *muxname, int val);
217 
218 /**
219  * omap_hwmod_mux_init - initialize hwmod specific mux data
220  * @bpads:              Board specific device signal names
221  * @nr_pads:            Number of signal names for the device
222  */
223 extern struct omap_hwmod_mux_info *
224 omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads);
225 
226 /**
227  * omap_hwmod_mux - omap hwmod specific pin muxing
228  * @hmux:               Pads for a hwmod
229  * @state:              Desired _HWMOD_STATE
230  *
231  * Called only from omap_hwmod.c, do not use.
232  */
233 void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state);
234 
235 int omap_mux_get_by_name(const char *muxname,
236                 struct omap_mux_partition **found_partition,
237                 struct omap_mux **found_mux);
238 #else
239 
240 static inline int omap_mux_get_by_name(const char *muxname,
241                 struct omap_mux_partition **found_partition,
242                 struct omap_mux **found_mux)
243 {
244         return 0;
245 }
246 
247 static inline int omap_mux_init_gpio(int gpio, int val)
248 {
249         return 0;
250 }
251 static inline int omap_mux_init_signal(char *muxname, int val)
252 {
253         return 0;
254 }
255 
256 static inline struct omap_hwmod_mux_info *
257 omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
258 {
259         return NULL;
260 }
261 
262 static inline void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
263 {
264 }
265 
266 static struct omap_board_mux *board_mux __maybe_unused;
267 
268 #endif
269 
270 /**
271  * omap_mux_get_gpio() - get mux register value based on GPIO number
272  * @gpio:               GPIO number
273  *
274  */
275 u16 omap_mux_get_gpio(int gpio);
276 
277 /**
278  * omap_mux_set_gpio() - set mux register value based on GPIO number
279  * @val:                New mux register value
280  * @gpio:               GPIO number
281  *
282  */
283 void omap_mux_set_gpio(u16 val, int gpio);
284 
285 /**
286  * omap_mux_get() - get a mux partition by name
287  * @name:               Name of the mux partition
288  *
289  */
290 struct omap_mux_partition *omap_mux_get(const char *name);
291 
292 /**
293  * omap_mux_read() - read mux register
294  * @partition:          Mux partition
295  * @mux_offset:         Offset of the mux register
296  *
297  */
298 u16 omap_mux_read(struct omap_mux_partition *p, u16 mux_offset);
299 
300 /**
301  * omap_mux_write() - write mux register
302  * @partition:          Mux partition
303  * @val:                New mux register value
304  * @mux_offset:         Offset of the mux register
305  *
306  * This should be only needed for dynamic remuxing of non-gpio signals.
307  */
308 void omap_mux_write(struct omap_mux_partition *p, u16 val, u16 mux_offset);
309 
310 /**
311  * omap_mux_write_array() - write an array of mux registers
312  * @partition:          Mux partition
313  * @board_mux:          Array of mux registers terminated by MAP_MUX_TERMINATOR
314  *
315  * This should be only needed for dynamic remuxing of non-gpio signals.
316  */
317 void omap_mux_write_array(struct omap_mux_partition *p,
318                           struct omap_board_mux *board_mux);
319 
320 /**
321  * omap2420_mux_init() - initialize mux system with board specific set
322  * @board_mux:          Board specific mux table
323  * @flags:              OMAP package type used for the board
324  */
325 int omap2420_mux_init(struct omap_board_mux *board_mux, int flags);
326 
327 /**
328  * omap2430_mux_init() - initialize mux system with board specific set
329  * @board_mux:          Board specific mux table
330  * @flags:              OMAP package type used for the board
331  */
332 int omap2430_mux_init(struct omap_board_mux *board_mux, int flags);
333 
334 /**
335  * omap3_mux_init() - initialize mux system with board specific set
336  * @board_mux:          Board specific mux table
337  * @flags:              OMAP package type used for the board
338  */
339 int omap3_mux_init(struct omap_board_mux *board_mux, int flags);
340 
341 /**
342  * omap4_mux_init() - initialize mux system with board specific set
343  * @board_subset:       Board specific mux table
344  * @board_wkup_subset:  Board specific mux table for wakeup instance
345  * @flags:              OMAP package type used for the board
346  */
347 int omap4_mux_init(struct omap_board_mux *board_subset,
348         struct omap_board_mux *board_wkup_subset, int flags);
349 
350 /**
351  * omap_mux_init - private mux init function, do not call
352  */
353 int omap_mux_init(const char *name, u32 flags,
354                   u32 mux_pbase, u32 mux_size,
355                   struct omap_mux *superset,
356                   struct omap_mux *package_subset,
357                   struct omap_board_mux *board_mux,
358                   struct omap_ball *package_balls);
359 
360 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp