Root/target/linux/ubicom32/files/arch/ubicom32/mach-common/plio.c

1/*
2 * plio.c
3 * PLIO state machine support functions
4 *
5 * Copyright © 2009 Ubicom Inc. <www.ubicom.com>. All rights reserved.
6 *
7 * This file is part of the Ubicom32 Linux Kernel Port.
8 *
9 * The Ubicom32 Linux Kernel Port is free software: you can
10 * redistribute it and/or modify it under the terms of the GNU General
11 * Public License as published by the Free Software Foundation, either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 * See the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port. If not,
21 * see <http://www.gnu.org/licenses/>.
22 */
23
24#include <linux/types.h>
25#include <linux/string.h>
26#include <linux/delay.h>
27#include <asm/plio.h>
28
29/*
30 * plio_reset
31 * Select and reset PLIO function
32 */
33static void plio_reset(const plio_fctl_t *plio_fctl) {
34    plio_io_function_t plio_function = {
35        .fn_sel = PLIO_FN,
36        .fn_reset = 1,
37    };
38
39    /*
40     * enable extension port
41     */
42    PEXT_NBR->function = plio_function;
43
44    /*
45     * program clock dividers
46     */
47    PLIO_NBR->fctl2 = plio_fctl->fctl2;
48
49    /*
50     * select plio function and assert function reset
51     */
52    plio_function.br_thread = thread_get_self();
53    plio_function.fn_reset = 1;
54    PLIO_NBR->function = plio_function;
55
56    /*
57     * program plio controls
58     */
59    PLIO_NBR->fctl0 = plio_fctl->fctl0;
60    PLIO_NBR->fctl1 = plio_fctl->fctl1;
61
62    /*
63     * deassert function reset
64     */
65    plio_function.fn_reset = 0;
66    PLIO_NBR->function = plio_function;
67}
68
69/*
70 * plio_init
71 * configure and initialize PLIO.
72 */
73void plio_init(const plio_fctl_t *plio_fctl, const plio_config_t *plio_config, const plio_sram_t plio_sram_cfg[], int sram_cfg_size){
74    /*
75     * first reset to start plio clock
76     */
77    plio_reset(plio_fctl);
78
79    udelay(1);
80
81    /*
82     * configure pfsm
83     */
84    PLIO_NBR->fctl0.pfsm_prog = 1;
85    memcpy(PLIO_BR->pfsm_sram, plio_sram_cfg, sram_cfg_size);
86    PLIO_NBR->fctl0.pfsm_prog = 0;
87
88    /*
89     * program rest of plio
90     */
91    memcpy(&PLIO_BR->config, plio_config, sizeof(plio_config_t));
92}
93

Archive Download this file



interactive