1*d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
225c7d49eSTony Lindgren /*
325c7d49eSTony Lindgren * omap_device headers
425c7d49eSTony Lindgren *
525c7d49eSTony Lindgren * Copyright (C) 2009 Nokia Corporation
625c7d49eSTony Lindgren * Paul Walmsley
725c7d49eSTony Lindgren *
825c7d49eSTony Lindgren * Developed in collaboration with (alphabetical order): Benoit
925c7d49eSTony Lindgren * Cousson, Kevin Hilman, Tony Lindgren, Rajendra Nayak, Vikram
1025c7d49eSTony Lindgren * Pandita, Sakari Poussa, Anand Sawant, Santosh Shilimkar, Richard
1125c7d49eSTony Lindgren * Woodruff
1225c7d49eSTony Lindgren *
13c1d1cd59SPaul Walmsley * This type of functionality should be implemented as a proper
14c1d1cd59SPaul Walmsley * omap_bus/omap_device in Linux.
1525c7d49eSTony Lindgren *
1625c7d49eSTony Lindgren * omap_device differs from omap_hwmod in that it includes external
1725c7d49eSTony Lindgren * (e.g., board- and system-level) integration details. omap_hwmod
1825c7d49eSTony Lindgren * stores hardware data that is invariant for a given OMAP chip.
1925c7d49eSTony Lindgren */
2025c7d49eSTony Lindgren #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
2125c7d49eSTony Lindgren #define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
2225c7d49eSTony Lindgren
2325c7d49eSTony Lindgren #include <linux/kernel.h>
2425c7d49eSTony Lindgren #include <linux/platform_device.h>
2525c7d49eSTony Lindgren
262a296c8fSTony Lindgren #include "omap_hwmod.h"
2725c7d49eSTony Lindgren
2825c7d49eSTony Lindgren /* omap_device._state values */
2925c7d49eSTony Lindgren #define OMAP_DEVICE_STATE_UNKNOWN 0
3025c7d49eSTony Lindgren #define OMAP_DEVICE_STATE_ENABLED 1
3125c7d49eSTony Lindgren #define OMAP_DEVICE_STATE_IDLE 2
3225c7d49eSTony Lindgren #define OMAP_DEVICE_STATE_SHUTDOWN 3
3325c7d49eSTony Lindgren
3425c7d49eSTony Lindgren /* omap_device.flags values */
3525c7d49eSTony Lindgren #define OMAP_DEVICE_SUSPENDED BIT(0)
3625c7d49eSTony Lindgren
3725c7d49eSTony Lindgren /**
3825c7d49eSTony Lindgren * struct omap_device - omap_device wrapper for platform_devices
3925c7d49eSTony Lindgren * @pdev: platform_device
4025c7d49eSTony Lindgren * @hwmods: (one .. many per omap_device)
4125c7d49eSTony Lindgren * @hwmods_cnt: ARRAY_SIZE() of @hwmods
4225c7d49eSTony Lindgren * @_state: one of OMAP_DEVICE_STATE_* (see above)
4325c7d49eSTony Lindgren * @flags: device flags
4425c7d49eSTony Lindgren * @_driver_status: one of BUS_NOTIFY_*_DRIVER from <linux/device.h>
4525c7d49eSTony Lindgren *
4625c7d49eSTony Lindgren * Integrates omap_hwmod data into Linux platform_device.
4725c7d49eSTony Lindgren *
4825c7d49eSTony Lindgren * Field names beginning with underscores are for the internal use of
4925c7d49eSTony Lindgren * the omap_device code.
5025c7d49eSTony Lindgren *
5125c7d49eSTony Lindgren */
5225c7d49eSTony Lindgren struct omap_device {
5325c7d49eSTony Lindgren struct platform_device *pdev;
5425c7d49eSTony Lindgren struct omap_hwmod **hwmods;
5525c7d49eSTony Lindgren unsigned long _driver_status;
5625c7d49eSTony Lindgren u8 hwmods_cnt;
5725c7d49eSTony Lindgren u8 _state;
5825c7d49eSTony Lindgren u8 flags;
5925c7d49eSTony Lindgren };
6025c7d49eSTony Lindgren
6125c7d49eSTony Lindgren /* Device driver interface (call via platform_data fn ptrs) */
6225c7d49eSTony Lindgren
6325c7d49eSTony Lindgren int omap_device_enable(struct platform_device *pdev);
6425c7d49eSTony Lindgren int omap_device_idle(struct platform_device *pdev);
6525c7d49eSTony Lindgren
6625c7d49eSTony Lindgren /* Other */
6725c7d49eSTony Lindgren
6825c7d49eSTony Lindgren int omap_device_assert_hardreset(struct platform_device *pdev,
6925c7d49eSTony Lindgren const char *name);
7025c7d49eSTony Lindgren int omap_device_deassert_hardreset(struct platform_device *pdev,
7125c7d49eSTony Lindgren const char *name);
7225c7d49eSTony Lindgren
7325c7d49eSTony Lindgren /* Get omap_device pointer from platform_device pointer */
to_omap_device(struct platform_device * pdev)7425c7d49eSTony Lindgren static inline struct omap_device *to_omap_device(struct platform_device *pdev)
7525c7d49eSTony Lindgren {
7625c7d49eSTony Lindgren return pdev ? pdev->archdata.od : NULL;
7725c7d49eSTony Lindgren }
7825c7d49eSTony Lindgren #endif
79