xref: /qemu/include/hw/ssi/aspeed_smc.h (revision 924ed16386ac8e079a9798f7de3b0d933fc3132c)
17c1c69bcSCédric Le Goater /*
27c1c69bcSCédric Le Goater  * ASPEED AST2400 SMC Controller (SPI Flash Only)
37c1c69bcSCédric Le Goater  *
47c1c69bcSCédric Le Goater  * Copyright (C) 2016 IBM Corp.
57c1c69bcSCédric Le Goater  *
67c1c69bcSCédric Le Goater  * Permission is hereby granted, free of charge, to any person obtaining a copy
77c1c69bcSCédric Le Goater  * of this software and associated documentation files (the "Software"), to deal
87c1c69bcSCédric Le Goater  * in the Software without restriction, including without limitation the rights
97c1c69bcSCédric Le Goater  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
107c1c69bcSCédric Le Goater  * copies of the Software, and to permit persons to whom the Software is
117c1c69bcSCédric Le Goater  * furnished to do so, subject to the following conditions:
127c1c69bcSCédric Le Goater  *
137c1c69bcSCédric Le Goater  * The above copyright notice and this permission notice shall be included in
147c1c69bcSCédric Le Goater  * all copies or substantial portions of the Software.
157c1c69bcSCédric Le Goater  *
167c1c69bcSCédric Le Goater  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
177c1c69bcSCédric Le Goater  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187c1c69bcSCédric Le Goater  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
197c1c69bcSCédric Le Goater  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
207c1c69bcSCédric Le Goater  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
217c1c69bcSCédric Le Goater  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
227c1c69bcSCédric Le Goater  * THE SOFTWARE.
237c1c69bcSCédric Le Goater  */
247c1c69bcSCédric Le Goater 
257c1c69bcSCédric Le Goater #ifndef ASPEED_SMC_H
267c1c69bcSCédric Le Goater #define ASPEED_SMC_H
277c1c69bcSCédric Le Goater 
287c1c69bcSCédric Le Goater #include "hw/ssi/ssi.h"
297c1c69bcSCédric Le Goater 
30*924ed163SCédric Le Goater typedef struct AspeedSegments {
31*924ed163SCédric Le Goater     hwaddr addr;
32*924ed163SCédric Le Goater     uint32_t size;
33*924ed163SCédric Le Goater } AspeedSegments;
34*924ed163SCédric Le Goater 
35*924ed163SCédric Le Goater struct AspeedSMCState;
367c1c69bcSCédric Le Goater typedef struct AspeedSMCController {
377c1c69bcSCédric Le Goater     const char *name;
387c1c69bcSCédric Le Goater     uint8_t r_conf;
397c1c69bcSCédric Le Goater     uint8_t r_ce_ctrl;
407c1c69bcSCédric Le Goater     uint8_t r_ctrl0;
417c1c69bcSCédric Le Goater     uint8_t r_timings;
427c1c69bcSCédric Le Goater     uint8_t conf_enable_w0;
437c1c69bcSCédric Le Goater     uint8_t max_slaves;
44*924ed163SCédric Le Goater     const AspeedSegments *segments;
45*924ed163SCédric Le Goater     uint32_t mapping_window_size;
467c1c69bcSCédric Le Goater } AspeedSMCController;
477c1c69bcSCédric Le Goater 
48*924ed163SCédric Le Goater typedef struct AspeedSMCFlash {
49*924ed163SCédric Le Goater     const struct AspeedSMCState *controller;
50*924ed163SCédric Le Goater 
51*924ed163SCédric Le Goater     uint8_t id;
52*924ed163SCédric Le Goater     uint32_t size;
53*924ed163SCédric Le Goater 
54*924ed163SCédric Le Goater     MemoryRegion mmio;
55*924ed163SCédric Le Goater     DeviceState *flash;
56*924ed163SCédric Le Goater } AspeedSMCFlash;
57*924ed163SCédric Le Goater 
587c1c69bcSCédric Le Goater #define TYPE_ASPEED_SMC "aspeed.smc"
597c1c69bcSCédric Le Goater #define ASPEED_SMC(obj) OBJECT_CHECK(AspeedSMCState, (obj), TYPE_ASPEED_SMC)
607c1c69bcSCédric Le Goater #define ASPEED_SMC_CLASS(klass) \
617c1c69bcSCédric Le Goater      OBJECT_CLASS_CHECK(AspeedSMCClass, (klass), TYPE_ASPEED_SMC)
627c1c69bcSCédric Le Goater #define ASPEED_SMC_GET_CLASS(obj) \
637c1c69bcSCédric Le Goater      OBJECT_GET_CLASS(AspeedSMCClass, (obj), TYPE_ASPEED_SMC)
647c1c69bcSCédric Le Goater 
657c1c69bcSCédric Le Goater typedef struct  AspeedSMCClass {
667c1c69bcSCédric Le Goater     SysBusDevice parent_obj;
677c1c69bcSCédric Le Goater     const AspeedSMCController *ctrl;
687c1c69bcSCédric Le Goater }  AspeedSMCClass;
697c1c69bcSCédric Le Goater 
707c1c69bcSCédric Le Goater #define ASPEED_SMC_R_MAX        (0x100 / 4)
717c1c69bcSCédric Le Goater 
727c1c69bcSCédric Le Goater typedef struct AspeedSMCState {
737c1c69bcSCédric Le Goater     SysBusDevice parent_obj;
747c1c69bcSCédric Le Goater 
757c1c69bcSCédric Le Goater     const AspeedSMCController *ctrl;
767c1c69bcSCédric Le Goater 
777c1c69bcSCédric Le Goater     MemoryRegion mmio;
78*924ed163SCédric Le Goater     MemoryRegion mmio_flash;
797c1c69bcSCédric Le Goater 
807c1c69bcSCédric Le Goater     qemu_irq irq;
817c1c69bcSCédric Le Goater     int irqline;
827c1c69bcSCédric Le Goater 
837c1c69bcSCédric Le Goater     uint32_t num_cs;
847c1c69bcSCédric Le Goater     qemu_irq *cs_lines;
857c1c69bcSCédric Le Goater 
867c1c69bcSCédric Le Goater     SSIBus *spi;
877c1c69bcSCédric Le Goater 
887c1c69bcSCédric Le Goater     uint32_t regs[ASPEED_SMC_R_MAX];
897c1c69bcSCédric Le Goater 
907c1c69bcSCédric Le Goater     /* depends on the controller type */
917c1c69bcSCédric Le Goater     uint8_t r_conf;
927c1c69bcSCédric Le Goater     uint8_t r_ce_ctrl;
937c1c69bcSCédric Le Goater     uint8_t r_ctrl0;
947c1c69bcSCédric Le Goater     uint8_t r_timings;
957c1c69bcSCédric Le Goater     uint8_t conf_enable_w0;
96*924ed163SCédric Le Goater 
97*924ed163SCédric Le Goater     AspeedSMCFlash *flashes;
987c1c69bcSCédric Le Goater } AspeedSMCState;
997c1c69bcSCédric Le Goater 
1007c1c69bcSCédric Le Goater #endif /* ASPEED_SMC_H */
101