1/*
2* Copyright 2019, 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#include <assert.h>
14#include <stdio.h>
15#include <camkes/io.h>
16#include <platsupport/io.h>
17#include <utils/util.h>
18
19#include "mux.h"
20
21/* Reference to the shared IO ops structure */
22static ps_io_ops_t *io_ops_ref;
23
24int mux_component_plat_init(ps_io_ops_t *io_ops) WEAK;
25
26int the_mux_feature_enable(mux_feature_t mux_feature, mux_gpio_dir_t mux_gpio_dir)
27{
28    return mux_feature_enable(&io_ops_ref->mux_sys, mux_feature, mux_gpio_dir);
29}
30
31int the_mux_feature_disable(mux_feature_t mux_feature)
32{
33    return mux_feature_disable(&io_ops_ref->mux_sys, mux_feature);
34}
35
36int mux_component_init(ps_io_ops_t *io_ops)
37{
38    int error = 0;
39
40    /* save a copy of the io_ops structure */
41    io_ops_ref = io_ops;
42
43    if (mux_component_plat_init) {
44        error = mux_component_plat_init(io_ops);
45    } else {
46        error = mux_sys_init(io_ops, NULL, &io_ops->mux_sys);
47    }
48
49    if (error) {
50        ZF_LOGE("Failed to initialise the MUX subsystem");
51    }
52
53    return error;
54}
55