3 * PLIO state machine support functions
5 * Copyright © 2009 Ubicom Inc. <www.ubicom.com>. All rights reserved.
7 * This file is part of the Ubicom32 Linux Kernel Port.
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.
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.
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/>.
24 #include <linux/types.h>
25 #include <linux/string.h>
26 #include <linux/delay.h>
31 * Select and reset PLIO function
33 static void plio_reset(const plio_fctl_t
*plio_fctl
) {
34 plio_io_function_t plio_function
= {
40 * enable extension port
42 PEXT_NBR
->function
= plio_function
;
45 * program clock dividers
47 PLIO_NBR
->fctl2
= plio_fctl
->fctl2
;
50 * select plio function and assert function reset
52 plio_function
.br_thread
= thread_get_self();
53 plio_function
.fn_reset
= 1;
54 PLIO_NBR
->function
= plio_function
;
57 * program plio controls
59 PLIO_NBR
->fctl0
= plio_fctl
->fctl0
;
60 PLIO_NBR
->fctl1
= plio_fctl
->fctl1
;
63 * deassert function reset
65 plio_function
.fn_reset
= 0;
66 PLIO_NBR
->function
= plio_function
;
71 * configure and initialize PLIO.
73 void 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
){
75 * first reset to start plio clock
77 plio_reset(plio_fctl
);
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;
89 * program rest of plio
91 memcpy(&PLIO_BR
->config
, plio_config
, sizeof(plio_config_t
));