^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * omap_device headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2009 Nokia Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Paul Walmsley
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Developed in collaboration with (alphabetical order): Benoit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Cousson, Kevin Hilman, Tony Lindgren, Rajendra Nayak, Vikram
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Pandita, Sakari Poussa, Anand Sawant, Santosh Shilimkar, Richard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Woodruff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This type of functionality should be implemented as a proper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * omap_bus/omap_device in Linux.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * omap_device differs from omap_hwmod in that it includes external
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * (e.g., board- and system-level) integration details. omap_hwmod
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * stores hardware data that is invariant for a given OMAP chip.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include "omap_hwmod.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) extern struct dev_pm_domain omap_device_pm_domain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) extern struct dev_pm_domain omap_device_fail_pm_domain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /* omap_device._state values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define OMAP_DEVICE_STATE_UNKNOWN 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define OMAP_DEVICE_STATE_ENABLED 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define OMAP_DEVICE_STATE_IDLE 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define OMAP_DEVICE_STATE_SHUTDOWN 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /* omap_device.flags values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define OMAP_DEVICE_SUSPENDED BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * struct omap_device - omap_device wrapper for platform_devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * @pdev: platform_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * @hwmods: (one .. many per omap_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * @hwmods_cnt: ARRAY_SIZE() of @hwmods
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * @_state: one of OMAP_DEVICE_STATE_* (see above)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * @flags: device flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * @_driver_status: one of BUS_NOTIFY_*_DRIVER from <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * Integrates omap_hwmod data into Linux platform_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * Field names beginning with underscores are for the internal use of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * the omap_device code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct omap_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct platform_device *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct omap_hwmod **hwmods;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) unsigned long _driver_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) u8 hwmods_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) u8 _state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) u8 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /* Device driver interface (call via platform_data fn ptrs) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) int omap_device_enable(struct platform_device *pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int omap_device_idle(struct platform_device *pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /* Core code interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct omap_device *omap_device_alloc(struct platform_device *pdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct omap_hwmod **ohs, int oh_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) void omap_device_delete(struct omap_device *od);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int omap_device_register(struct platform_device *pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct device *omap_device_get_by_hwmod_name(const char *oh_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* OMAP PM interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) int omap_device_get_context_loss_count(struct platform_device *pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* Other */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) int omap_device_assert_hardreset(struct platform_device *pdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int omap_device_deassert_hardreset(struct platform_device *pdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /* Get omap_device pointer from platform_device pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) static inline struct omap_device *to_omap_device(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) return pdev ? pdev->archdata.od : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #endif