Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 1 | /* |
| 2 | * omap_device headers |
| 3 | * |
| 4 | * Copyright (C) 2009 Nokia Corporation |
| 5 | * Paul Walmsley |
| 6 | * |
| 7 | * Developed in collaboration with (alphabetical order): Benoit |
| 8 | * Cousson, Kevin Hilman, Tony Lindgren, Rajendra Nayak, Vikram |
| 9 | * Pandita, Sakari Poussa, Anand Sawant, Santosh Shilimkar, Richard |
| 10 | * Woodruff |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License version 2 as |
| 14 | * published by the Free Software Foundation. |
| 15 | * |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame] | 16 | * This type of functionality should be implemented as a proper |
| 17 | * omap_bus/omap_device in Linux. |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 18 | * |
| 19 | * omap_device differs from omap_hwmod in that it includes external |
| 20 | * (e.g., board- and system-level) integration details. omap_hwmod |
| 21 | * stores hardware data that is invariant for a given OMAP chip. |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 22 | */ |
| 23 | #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H |
| 24 | #define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H |
| 25 | |
| 26 | #include <linux/kernel.h> |
| 27 | #include <linux/platform_device.h> |
| 28 | |
Tony Lindgren | 2a296c8 | 2012-10-02 17:41:35 -0700 | [diff] [blame] | 29 | #include "omap_hwmod.h" |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 30 | |
Kevin Hilman | 3ec2dec | 2012-02-15 11:47:45 -0800 | [diff] [blame] | 31 | extern struct dev_pm_domain omap_device_pm_domain; |
Kevin Hilman | 0d5e825 | 2010-08-23 08:10:55 -0700 | [diff] [blame] | 32 | |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 33 | /* omap_device._state values */ |
| 34 | #define OMAP_DEVICE_STATE_UNKNOWN 0 |
| 35 | #define OMAP_DEVICE_STATE_ENABLED 1 |
| 36 | #define OMAP_DEVICE_STATE_IDLE 2 |
| 37 | #define OMAP_DEVICE_STATE_SHUTDOWN 3 |
| 38 | |
Kevin Hilman | c03f007 | 2011-07-12 22:48:19 +0200 | [diff] [blame] | 39 | /* omap_device.flags values */ |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame] | 40 | #define OMAP_DEVICE_SUSPENDED BIT(0) |
| 41 | #define OMAP_DEVICE_NO_IDLE_ON_SUSPEND BIT(1) |
Kevin Hilman | c03f007 | 2011-07-12 22:48:19 +0200 | [diff] [blame] | 42 | |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 43 | /** |
| 44 | * struct omap_device - omap_device wrapper for platform_devices |
| 45 | * @pdev: platform_device |
| 46 | * @hwmods: (one .. many per omap_device) |
| 47 | * @hwmods_cnt: ARRAY_SIZE() of @hwmods |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 48 | * @_state: one of OMAP_DEVICE_STATE_* (see above) |
| 49 | * @flags: device flags |
Kevin Hilman | e753345 | 2012-07-10 11:13:16 -0700 | [diff] [blame] | 50 | * @_driver_status: one of BUS_NOTIFY_*_DRIVER from <linux/device.h> |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 51 | * |
| 52 | * Integrates omap_hwmod data into Linux platform_device. |
| 53 | * |
| 54 | * Field names beginning with underscores are for the internal use of |
| 55 | * the omap_device code. |
| 56 | * |
| 57 | */ |
| 58 | struct omap_device { |
Kevin Hilman | d66b3fe | 2011-07-21 13:58:51 -0700 | [diff] [blame] | 59 | struct platform_device *pdev; |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 60 | struct omap_hwmod **hwmods; |
Kevin Hilman | e753345 | 2012-07-10 11:13:16 -0700 | [diff] [blame] | 61 | unsigned long _driver_status; |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 62 | u8 hwmods_cnt; |
| 63 | u8 _state; |
Kevin Hilman | c03f007 | 2011-07-12 22:48:19 +0200 | [diff] [blame] | 64 | u8 flags; |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | /* Device driver interface (call via platform_data fn ptrs) */ |
| 68 | |
| 69 | int omap_device_enable(struct platform_device *pdev); |
| 70 | int omap_device_idle(struct platform_device *pdev); |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 71 | |
| 72 | /* Core code interface */ |
| 73 | |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 74 | struct platform_device *omap_device_build(const char *pdev_name, int pdev_id, |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame] | 75 | struct omap_hwmod *oh, void *pdata, |
| 76 | int pdata_len); |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 77 | |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 78 | struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id, |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 79 | struct omap_hwmod **oh, int oh_cnt, |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame] | 80 | void *pdata, int pdata_len); |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 81 | |
Ohad Ben-Cohen | 993e4fb | 2012-02-20 09:43:29 -0800 | [diff] [blame] | 82 | struct omap_device *omap_device_alloc(struct platform_device *pdev, |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame] | 83 | struct omap_hwmod **ohs, int oh_cnt); |
Ohad Ben-Cohen | 993e4fb | 2012-02-20 09:43:29 -0800 | [diff] [blame] | 84 | void omap_device_delete(struct omap_device *od); |
| 85 | int omap_device_register(struct platform_device *pdev); |
| 86 | |
Nishanth Menon | 1f8a7d5 | 2011-07-27 15:02:32 -0500 | [diff] [blame] | 87 | struct device *omap_device_get_by_hwmod_name(const char *oh_name); |
Paul Walmsley | db2a60b | 2010-07-26 16:34:33 -0600 | [diff] [blame] | 88 | |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 89 | /* OMAP PM interface */ |
Tomi Valkeinen | fc01387 | 2011-06-09 16:56:23 +0300 | [diff] [blame] | 90 | int omap_device_get_context_loss_count(struct platform_device *pdev); |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 91 | |
| 92 | /* Other */ |
| 93 | |
Omar Ramirez Luna | 8bb9fde | 2012-09-23 17:28:18 -0600 | [diff] [blame] | 94 | int omap_device_assert_hardreset(struct platform_device *pdev, |
| 95 | const char *name); |
| 96 | int omap_device_deassert_hardreset(struct platform_device *pdev, |
| 97 | const char *name); |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 98 | |
Kevin Hilman | a470c42 | 2009-12-08 16:34:17 -0700 | [diff] [blame] | 99 | /* Get omap_device pointer from platform_device pointer */ |
Kevin Hilman | d66b3fe | 2011-07-21 13:58:51 -0700 | [diff] [blame] | 100 | static inline struct omap_device *to_omap_device(struct platform_device *pdev) |
| 101 | { |
| 102 | return pdev ? pdev->archdata.od : NULL; |
| 103 | } |
Paul Walmsley | b04b65a | 2009-09-03 20:14:05 +0300 | [diff] [blame] | 104 | |
Kevin Hilman | 9f8b694 | 2011-08-01 09:33:13 -0700 | [diff] [blame] | 105 | static inline |
| 106 | void omap_device_disable_idle_on_suspend(struct platform_device *pdev) |
| 107 | { |
| 108 | struct omap_device *od = to_omap_device(pdev); |
| 109 | |
| 110 | od->flags |= OMAP_DEVICE_NO_IDLE_ON_SUSPEND; |
| 111 | } |
| 112 | |
Kevin Hilman | a470c42 | 2009-12-08 16:34:17 -0700 | [diff] [blame] | 113 | #endif |