1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(DATA61_BSD)
11 */
12
13#pragma once
14
15#include <platsupport/mux.h>
16#include <platsupport/plat/mux.h>
17
18/* Value encodings */
19#define MUXVALUE_CPD(con, pud, drv) ((con) << 0 | (pud) << 4 | (drv) << 6)
20#define MUXVALUE_CON(mval)          (((mval) >> 0) & 0xf)
21#define MUXVALUE_PUD(mval)          (((mval) >> 4) & 0x3)
22#define MUXVALUE_DRV(mval)          (((mval) >> 6) & 0x3)
23/* PUD values */
24#define PUD_NONE     0x0
25#define PUD_PULLDOWN 0x1
26#define PUD_PULLUP   0x3
27/* DRV values */
28#define DRV1X        0x0
29#define DRV2X        0x2
30#define DRV3X        0x1
31#define DRV4X        0x3
32
33struct mux_cfg {
34    uint32_t con;
35    uint32_t dat;
36    uint32_t pud;
37    uint32_t drv;
38    uint32_t conpdn;
39    uint32_t pudpdn;
40    uint32_t res[2];
41};
42/* 448 */
43struct mux_bank {
44    struct mux_cfg gp[22];
45    uint32_t res0[272];               /* 0x2C0 */
46    uint32_t ext_int_con[22];         /* 0x700 */
47    uint32_t res1[42];
48    uint32_t ext_int_fltcon[22][2];   /* 0x800 */
49    uint32_t res2[20];
50    uint32_t ext_int_mask[22];        /* 0x900 */
51    uint32_t res3[42];
52    uint32_t ext_int_pend[22];        /* 0xA00 */
53    uint32_t res4[42];
54    uint32_t ext_int_grppri_xa;       /* 0xB00 */
55    uint32_t ext_int_priority_xa;
56    uint32_t ext_int_service_xa;
57    uint32_t ext_int_service_pend_xa;
58    uint32_t ext_int_grpfixpri_xa;
59    uint32_t ext_int_fixpri[22];      /* 0xB14 */
60    uint32_t res5[37];
61    struct mux_cfg xgp[4];            /* 0xC00 */
62    uint32_t res6[96];
63    uint32_t ext_xint_con[4];        /* 0xE00 */
64    uint32_t res7[28];
65    uint32_t ext_xint_fltcon[4][2];  /* 0xE80 */
66    uint32_t res8[24];
67    uint32_t ext_xint_mask[4];       /* 0xF00 */
68    uint32_t res9[12];
69    uint32_t ext_xint_pend[4];       /* 0xF40 */
70    uint32_t res10[44];
71};
72
73struct mux_feature_data {
74    uint16_t port;
75    uint8_t pin;
76    uint8_t value;
77};
78
79extern struct mux_feature_data* feature_data[];
80
81