^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) * PS3 platform declarations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2006 Sony Computer Entertainment Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright 2006 Sony Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #if !defined(_ASM_POWERPC_PS3_H)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define _ASM_POWERPC_PS3_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/cell-pmu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) union ps3_firmware_version {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) u64 raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) u16 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) u16 major;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) u16 minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) u16 rev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) void ps3_get_firmware_version(union ps3_firmware_version *v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /* 'Other OS' area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) enum ps3_param_av_multi_out {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) PS3_PARAM_AV_MULTI_OUT_NTSC = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) PS3_PARAM_AV_MULTI_OUT_PAL_RGB = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) PS3_PARAM_AV_MULTI_OUT_PAL_YCBCR = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) PS3_PARAM_AV_MULTI_OUT_SECAM = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) extern u64 ps3_os_area_get_rtc_diff(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) extern void ps3_os_area_set_rtc_diff(u64 rtc_diff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct ps3_os_area_flash_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ssize_t (*read)(void *buf, size_t count, loff_t pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) ssize_t (*write)(const void *buf, size_t count, loff_t pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) extern void ps3_os_area_flash_register(const struct ps3_os_area_flash_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* dma routines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) enum ps3_dma_page_size {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) PS3_DMA_4K = 12U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) PS3_DMA_64K = 16U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) PS3_DMA_1M = 20U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) PS3_DMA_16M = 24U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) enum ps3_dma_region_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) PS3_DMA_OTHER = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) PS3_DMA_INTERNAL = 2,
^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) struct ps3_dma_region_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * struct ps3_dma_region - A per device dma state variables structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * @did: The HV device id.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * @page_size: The ioc pagesize.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * @region_type: The HV region type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * @bus_addr: The 'translated' bus address of the region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * @len: The length in bytes of the region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * @offset: The offset from the start of memory of the region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * @dma_mask: Device dma_mask.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * @ioid: The IOID of the device who owns this region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * @chunk_list: Opaque variable used by the ioc page manager.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * @region_ops: struct ps3_dma_region_ops - dma region operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct ps3_dma_region {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct ps3_system_bus_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) /* device variables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) const struct ps3_dma_region_ops *region_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) unsigned char ioid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) enum ps3_dma_page_size page_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) enum ps3_dma_region_type region_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) unsigned long len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) unsigned long offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) u64 dma_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /* driver variables (set by ps3_dma_region_create) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) unsigned long bus_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct list_head head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) } chunk_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct ps3_dma_region_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) int (*create)(struct ps3_dma_region *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) int (*free)(struct ps3_dma_region *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) int (*map)(struct ps3_dma_region *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) unsigned long virt_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) unsigned long len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) dma_addr_t *bus_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) u64 iopte_pp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int (*unmap)(struct ps3_dma_region *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) dma_addr_t bus_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) unsigned long len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * struct ps3_dma_region_init - Helper to initialize structure variables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * Helper to properly initialize variables prior to calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * ps3_system_bus_device_register.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct ps3_system_bus_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int ps3_dma_region_init(struct ps3_system_bus_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct ps3_dma_region *r, enum ps3_dma_page_size page_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) enum ps3_dma_region_type region_type, void *addr, unsigned long len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int ps3_dma_region_create(struct ps3_dma_region *r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) int ps3_dma_region_free(struct ps3_dma_region *r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) unsigned long len, dma_addr_t *bus_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) u64 iopte_pp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int ps3_dma_unmap(struct ps3_dma_region *r, dma_addr_t bus_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) unsigned long len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /* mmio routines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) enum ps3_mmio_page_size {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) PS3_MMIO_4K = 12U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) PS3_MMIO_64K = 16U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct ps3_mmio_region_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * struct ps3_mmio_region - a per device mmio state variables structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * Current systems can be supported with a single region per device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct ps3_mmio_region {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct ps3_system_bus_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) const struct ps3_mmio_region_ops *mmio_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) unsigned long bus_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) unsigned long len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) enum ps3_mmio_page_size page_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) unsigned long lpar_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct ps3_mmio_region_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) int (*create)(struct ps3_mmio_region *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) int (*free)(struct ps3_mmio_region *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * struct ps3_mmio_region_init - Helper to initialize structure variables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * Helper to properly initialize variables prior to calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * ps3_system_bus_device_register.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int ps3_mmio_region_init(struct ps3_system_bus_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct ps3_mmio_region *r, unsigned long bus_addr, unsigned long len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) enum ps3_mmio_page_size page_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) int ps3_mmio_region_create(struct ps3_mmio_region *r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) int ps3_free_mmio_region(struct ps3_mmio_region *r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) unsigned long ps3_mm_phys_to_lpar(unsigned long phys_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /* inrerrupt routines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) enum ps3_cpu_binding {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) PS3_BINDING_CPU_ANY = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) PS3_BINDING_CPU_0 = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) PS3_BINDING_CPU_1 = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) int ps3_irq_plug_setup(enum ps3_cpu_binding cpu, unsigned long outlet,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) unsigned int *virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) int ps3_irq_plug_destroy(unsigned int virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) int ps3_event_receive_port_setup(enum ps3_cpu_binding cpu, unsigned int *virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int ps3_event_receive_port_destroy(unsigned int virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) int ps3_send_event_locally(unsigned int virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) int ps3_io_irq_setup(enum ps3_cpu_binding cpu, unsigned int interrupt_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) unsigned int *virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) int ps3_io_irq_destroy(unsigned int virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) int ps3_vuart_irq_setup(enum ps3_cpu_binding cpu, void* virt_addr_bmp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) unsigned int *virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) int ps3_vuart_irq_destroy(unsigned int virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) int ps3_spe_irq_setup(enum ps3_cpu_binding cpu, unsigned long spe_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) unsigned int class, unsigned int *virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) int ps3_spe_irq_destroy(unsigned int virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) int ps3_sb_event_receive_port_setup(struct ps3_system_bus_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) enum ps3_cpu_binding cpu, unsigned int *virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) int ps3_sb_event_receive_port_destroy(struct ps3_system_bus_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) unsigned int virq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) /* lv1 result codes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) enum lv1_result {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) LV1_SUCCESS = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /* not used -1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) LV1_RESOURCE_SHORTAGE = -2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) LV1_NO_PRIVILEGE = -3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) LV1_DENIED_BY_POLICY = -4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) LV1_ACCESS_VIOLATION = -5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) LV1_NO_ENTRY = -6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) LV1_DUPLICATE_ENTRY = -7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) LV1_TYPE_MISMATCH = -8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) LV1_BUSY = -9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) LV1_EMPTY = -10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) LV1_WRONG_STATE = -11,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /* not used -12 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) LV1_NO_MATCH = -13,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) LV1_ALREADY_CONNECTED = -14,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) LV1_UNSUPPORTED_PARAMETER_VALUE = -15,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) LV1_CONDITION_NOT_SATISFIED = -16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) LV1_ILLEGAL_PARAMETER_VALUE = -17,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) LV1_BAD_OPTION = -18,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) LV1_IMPLEMENTATION_LIMITATION = -19,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) LV1_NOT_IMPLEMENTED = -20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) LV1_INVALID_CLASS_ID = -21,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) LV1_CONSTRAINT_NOT_SATISFIED = -22,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) LV1_ALIGNMENT_ERROR = -23,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) LV1_HARDWARE_ERROR = -24,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) LV1_INVALID_DATA_FORMAT = -25,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) LV1_INVALID_OPERATION = -26,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) LV1_INTERNAL_ERROR = -32768,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static inline const char* ps3_result(int result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) #if defined(DEBUG) || defined(PS3_VERBOSE_RESULT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) switch (result) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) case LV1_SUCCESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return "LV1_SUCCESS (0)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) case -1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) return "** unknown result ** (-1)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) case LV1_RESOURCE_SHORTAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) return "LV1_RESOURCE_SHORTAGE (-2)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) case LV1_NO_PRIVILEGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) return "LV1_NO_PRIVILEGE (-3)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) case LV1_DENIED_BY_POLICY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) return "LV1_DENIED_BY_POLICY (-4)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) case LV1_ACCESS_VIOLATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) return "LV1_ACCESS_VIOLATION (-5)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) case LV1_NO_ENTRY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return "LV1_NO_ENTRY (-6)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) case LV1_DUPLICATE_ENTRY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) return "LV1_DUPLICATE_ENTRY (-7)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) case LV1_TYPE_MISMATCH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) return "LV1_TYPE_MISMATCH (-8)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) case LV1_BUSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) return "LV1_BUSY (-9)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) case LV1_EMPTY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return "LV1_EMPTY (-10)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) case LV1_WRONG_STATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) return "LV1_WRONG_STATE (-11)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) case -12:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) return "** unknown result ** (-12)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) case LV1_NO_MATCH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) return "LV1_NO_MATCH (-13)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) case LV1_ALREADY_CONNECTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) return "LV1_ALREADY_CONNECTED (-14)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) case LV1_UNSUPPORTED_PARAMETER_VALUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) return "LV1_UNSUPPORTED_PARAMETER_VALUE (-15)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) case LV1_CONDITION_NOT_SATISFIED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) return "LV1_CONDITION_NOT_SATISFIED (-16)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) case LV1_ILLEGAL_PARAMETER_VALUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) return "LV1_ILLEGAL_PARAMETER_VALUE (-17)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) case LV1_BAD_OPTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) return "LV1_BAD_OPTION (-18)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) case LV1_IMPLEMENTATION_LIMITATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) return "LV1_IMPLEMENTATION_LIMITATION (-19)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) case LV1_NOT_IMPLEMENTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) return "LV1_NOT_IMPLEMENTED (-20)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) case LV1_INVALID_CLASS_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return "LV1_INVALID_CLASS_ID (-21)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) case LV1_CONSTRAINT_NOT_SATISFIED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) return "LV1_CONSTRAINT_NOT_SATISFIED (-22)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) case LV1_ALIGNMENT_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) return "LV1_ALIGNMENT_ERROR (-23)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) case LV1_HARDWARE_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) return "LV1_HARDWARE_ERROR (-24)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) case LV1_INVALID_DATA_FORMAT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) return "LV1_INVALID_DATA_FORMAT (-25)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) case LV1_INVALID_OPERATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) return "LV1_INVALID_OPERATION (-26)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) case LV1_INTERNAL_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) return "LV1_INTERNAL_ERROR (-32768)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) return "** unknown result **";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) return "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) /* system bus routines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) enum ps3_match_id {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) PS3_MATCH_ID_EHCI = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) PS3_MATCH_ID_OHCI = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) PS3_MATCH_ID_GELIC = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) PS3_MATCH_ID_AV_SETTINGS = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) PS3_MATCH_ID_SYSTEM_MANAGER = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) PS3_MATCH_ID_STOR_DISK = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) PS3_MATCH_ID_STOR_ROM = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) PS3_MATCH_ID_STOR_FLASH = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) PS3_MATCH_ID_SOUND = 9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) PS3_MATCH_ID_GPU = 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) PS3_MATCH_ID_LPM = 11,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) enum ps3_match_sub_id {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) PS3_MATCH_SUB_ID_GPU_FB = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) PS3_MATCH_SUB_ID_GPU_RAMDISK = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) #define PS3_MODULE_ALIAS_EHCI "ps3:1:0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) #define PS3_MODULE_ALIAS_OHCI "ps3:2:0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) #define PS3_MODULE_ALIAS_GELIC "ps3:3:0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) #define PS3_MODULE_ALIAS_AV_SETTINGS "ps3:4:0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) #define PS3_MODULE_ALIAS_SYSTEM_MANAGER "ps3:5:0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) #define PS3_MODULE_ALIAS_STOR_DISK "ps3:6:0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) #define PS3_MODULE_ALIAS_STOR_ROM "ps3:7:0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) #define PS3_MODULE_ALIAS_STOR_FLASH "ps3:8:0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) #define PS3_MODULE_ALIAS_SOUND "ps3:9:0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) #define PS3_MODULE_ALIAS_GPU_FB "ps3:10:1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) #define PS3_MODULE_ALIAS_GPU_RAMDISK "ps3:10:2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) #define PS3_MODULE_ALIAS_LPM "ps3:11:0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) enum ps3_system_bus_device_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) PS3_DEVICE_TYPE_IOC0 = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) PS3_DEVICE_TYPE_SB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) PS3_DEVICE_TYPE_VUART,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) PS3_DEVICE_TYPE_LPM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * struct ps3_system_bus_device - a device on the system bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) struct ps3_system_bus_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) enum ps3_match_id match_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) enum ps3_match_sub_id match_sub_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) enum ps3_system_bus_device_type dev_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) u64 bus_id; /* SB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) u64 dev_id; /* SB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) unsigned int interrupt_id; /* SB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) struct ps3_dma_region *d_region; /* SB, IOC0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) struct ps3_mmio_region *m_region; /* SB, IOC0*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) unsigned int port_number; /* VUART */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) struct { /* LPM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) u64 node_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) u64 pu_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) u64 rights;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) } lpm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) /* struct iommu_table *iommu_table; -- waiting for BenH's cleanups */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) struct device core;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) void *driver_priv; /* private driver variables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) int ps3_open_hv_device(struct ps3_system_bus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) int ps3_close_hv_device(struct ps3_system_bus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * struct ps3_system_bus_driver - a driver for a device on the system bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) struct ps3_system_bus_driver {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) enum ps3_match_id match_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) enum ps3_match_sub_id match_sub_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) struct device_driver core;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) int (*probe)(struct ps3_system_bus_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) int (*remove)(struct ps3_system_bus_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) int (*shutdown)(struct ps3_system_bus_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) /* int (*resume)(struct ps3_system_bus_device *); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) int ps3_system_bus_device_register(struct ps3_system_bus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) static inline struct ps3_system_bus_driver *ps3_drv_to_system_bus_drv(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) struct device_driver *_drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) return container_of(_drv, struct ps3_system_bus_driver, core);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) static inline struct ps3_system_bus_device *ps3_dev_to_system_bus_dev(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) struct device *_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) return container_of(_dev, struct ps3_system_bus_device, core);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) static inline struct ps3_system_bus_driver *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) ps3_system_bus_dev_to_system_bus_drv(struct ps3_system_bus_device *_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) BUG_ON(!_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) BUG_ON(!_dev->core.driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) return ps3_drv_to_system_bus_drv(_dev->core.driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * ps3_system_bus_set_drvdata -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) * @dev: device structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) * @data: Data to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) static inline void ps3_system_bus_set_drvdata(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) struct ps3_system_bus_device *dev, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) dev_set_drvdata(&dev->core, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) static inline void *ps3_system_bus_get_drvdata(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) struct ps3_system_bus_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) return dev_get_drvdata(&dev->core);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) /* These two need global scope for get_arch_dma_ops(). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) extern struct bus_type ps3_system_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) /* system manager */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) struct ps3_sys_manager_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) struct ps3_system_bus_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) void (*power_off)(struct ps3_system_bus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) void (*restart)(struct ps3_system_bus_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) void __noreturn ps3_sys_manager_power_off(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) void __noreturn ps3_sys_manager_restart(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) void __noreturn ps3_sys_manager_halt(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) int ps3_sys_manager_get_wol(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) void ps3_sys_manager_set_wol(int state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) struct ps3_prealloc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) void *address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) unsigned long size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) unsigned long align;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) extern struct ps3_prealloc ps3fb_videomemory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) extern struct ps3_prealloc ps3flash_bounce_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) /* logical performance monitor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) * enum ps3_lpm_rights - Rigths granted by the system policy module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) * @PS3_LPM_RIGHTS_USE_LPM: The right to use the lpm.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * @PS3_LPM_RIGHTS_USE_TB: The right to use the internal trace buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) enum ps3_lpm_rights {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) PS3_LPM_RIGHTS_USE_LPM = 0x001,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) PS3_LPM_RIGHTS_USE_TB = 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) * enum ps3_lpm_tb_type - Type of trace buffer lv1 should use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) * @PS3_LPM_TB_TYPE_NONE: Do not use a trace buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) * @PS3_LPM_RIGHTS_USE_TB: Use the lv1 internal trace buffer. Must have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) * rights @PS3_LPM_RIGHTS_USE_TB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) enum ps3_lpm_tb_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) PS3_LPM_TB_TYPE_NONE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) PS3_LPM_TB_TYPE_INTERNAL = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) u64 tb_cache_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) int ps3_lpm_close(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) int ps3_lpm_copy_tb(unsigned long offset, void *buf, unsigned long count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) unsigned long *bytes_copied);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) int ps3_lpm_copy_tb_to_user(unsigned long offset, void __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) unsigned long count, unsigned long *bytes_copied);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) void ps3_set_bookmark(u64 bookmark);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) void ps3_set_pm_bookmark(u64 tag, u64 incident, u64 th_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) int ps3_set_signal(u64 rtas_signal_group, u8 signal_bit, u16 sub_unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) u8 bus_word);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) u32 ps3_read_phys_ctr(u32 cpu, u32 phys_ctr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) void ps3_write_phys_ctr(u32 cpu, u32 phys_ctr, u32 val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) u32 ps3_read_ctr(u32 cpu, u32 ctr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) void ps3_write_ctr(u32 cpu, u32 ctr, u32 val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) u32 ps3_read_pm07_control(u32 cpu, u32 ctr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) void ps3_write_pm07_control(u32 cpu, u32 ctr, u32 val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) u32 ps3_read_pm(u32 cpu, enum pm_reg_name reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) void ps3_write_pm(u32 cpu, enum pm_reg_name reg, u32 val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) u32 ps3_get_ctr_size(u32 cpu, u32 phys_ctr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) void ps3_set_ctr_size(u32 cpu, u32 phys_ctr, u32 ctr_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) void ps3_enable_pm(u32 cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) void ps3_disable_pm(u32 cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) void ps3_enable_pm_interrupts(u32 cpu, u32 thread, u32 mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) void ps3_disable_pm_interrupts(u32 cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) u32 ps3_get_and_clear_pm_interrupts(u32 cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) void ps3_sync_irq(int node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) u32 ps3_get_hw_thread_id(int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) u64 ps3_get_spe_id(void *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) void ps3_early_mm_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) #endif