1f83a40dcSAlexander Graf /* 2f83a40dcSAlexander Graf * QEMU AHCI Emulation 3f83a40dcSAlexander Graf * 4f83a40dcSAlexander Graf * Copyright (c) 2010 qiaochong@loongson.cn 5f83a40dcSAlexander Graf * Copyright (c) 2010 Roland Elek <elek.roland@gmail.com> 6f83a40dcSAlexander Graf * Copyright (c) 2010 Sebastian Herbszt <herbszt@gmx.de> 7f83a40dcSAlexander Graf * Copyright (c) 2010 Alexander Graf <agraf@suse.de> 8f83a40dcSAlexander Graf * 9f83a40dcSAlexander Graf * This library is free software; you can redistribute it and/or 10f83a40dcSAlexander Graf * modify it under the terms of the GNU Lesser General Public 11f83a40dcSAlexander Graf * License as published by the Free Software Foundation; either 1261f3c91aSChetan Pant * version 2.1 of the License, or (at your option) any later version. 13f83a40dcSAlexander Graf * 14f83a40dcSAlexander Graf * This library is distributed in the hope that it will be useful, 15f83a40dcSAlexander Graf * but WITHOUT ANY WARRANTY; without even the implied warranty of 16f83a40dcSAlexander Graf * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17f83a40dcSAlexander Graf * Lesser General Public License for more details. 18f83a40dcSAlexander Graf * 19f83a40dcSAlexander Graf * You should have received a copy of the GNU Lesser General Public 20f83a40dcSAlexander Graf * License along with this library; if not, see <http://www.gnu.org/licenses/>. 21f83a40dcSAlexander Graf * 22f83a40dcSAlexander Graf */ 23f83a40dcSAlexander Graf 2470e23370SJohn Snow #ifndef HW_IDE_AHCI_H 2570e23370SJohn Snow #define HW_IDE_AHCI_H 2603c7a6a8SSebastian Herbszt 27a9c94277SMarkus Armbruster #include "hw/sysbus.h" 28db1015e9SEduardo Habkost #include "qom/object.h" 295ea8b9c5SAlistair Francis 3070e23370SJohn Snow typedef struct AHCIDevice AHCIDevice; 3103c7a6a8SSebastian Herbszt 3270e23370SJohn Snow typedef struct AHCIControlRegs { 3370e23370SJohn Snow uint32_t cap; 3470e23370SJohn Snow uint32_t ghc; 3570e23370SJohn Snow uint32_t irqstatus; 3670e23370SJohn Snow uint32_t impl; 3770e23370SJohn Snow uint32_t version; 3870e23370SJohn Snow } AHCIControlRegs; 3903c7a6a8SSebastian Herbszt 4070e23370SJohn Snow typedef struct AHCIState { 4170e23370SJohn Snow DeviceState *container; 4203c7a6a8SSebastian Herbszt 4370e23370SJohn Snow AHCIDevice *dev; 4470e23370SJohn Snow AHCIControlRegs control_regs; 4570e23370SJohn Snow MemoryRegion mem; 4670e23370SJohn Snow MemoryRegion idp; /* Index-Data Pair I/O port space */ 4770e23370SJohn Snow unsigned idp_offset; /* Offset of index in I/O port space */ 4870e23370SJohn Snow uint32_t idp_index; /* Current IDP index */ 4970e23370SJohn Snow int32_t ports; 5070e23370SJohn Snow qemu_irq irq; 5170e23370SJohn Snow AddressSpace *as; 5270e23370SJohn Snow } AHCIState; 5303c7a6a8SSebastian Herbszt 5403c7a6a8SSebastian Herbszt 55*e2f8d280SPhilippe Mathieu-Daudé void ahci_ide_create_devs(AHCIState *ahci, DriveInfo **hd); 5603c7a6a8SSebastian Herbszt 575ea8b9c5SAlistair Francis #define TYPE_SYSBUS_AHCI "sysbus-ahci" 588063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(SysbusAHCIState, SYSBUS_AHCI) 595ea8b9c5SAlistair Francis 60db1015e9SEduardo Habkost struct SysbusAHCIState { 6170e23370SJohn Snow /*< private >*/ 6270e23370SJohn Snow SysBusDevice parent_obj; 6370e23370SJohn Snow /*< public >*/ 6470e23370SJohn Snow 6570e23370SJohn Snow AHCIState ahci; 6670e23370SJohn Snow uint32_t num_ports; 67db1015e9SEduardo Habkost }; 6870e23370SJohn Snow 69377e2145SPeter Crosthwaite #define TYPE_ALLWINNER_AHCI "allwinner-ahci" 708063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(AllwinnerAHCIState, ALLWINNER_AHCI) 71377e2145SPeter Crosthwaite 7270e23370SJohn Snow #define ALLWINNER_AHCI_MMIO_OFF 0x80 7370e23370SJohn Snow #define ALLWINNER_AHCI_MMIO_SIZE 0x80 7470e23370SJohn Snow 75db1015e9SEduardo Habkost struct AllwinnerAHCIState { 7670e23370SJohn Snow /*< private >*/ 7770e23370SJohn Snow SysbusAHCIState parent_obj; 7870e23370SJohn Snow /*< public >*/ 7970e23370SJohn Snow 8070e23370SJohn Snow MemoryRegion mmio; 8170e23370SJohn Snow uint32_t regs[ALLWINNER_AHCI_MMIO_SIZE/4]; 82db1015e9SEduardo Habkost }; 8370e23370SJohn Snow 8403c7a6a8SSebastian Herbszt #endif /* HW_IDE_AHCI_H */ 85