diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index afa16c6c51..a882194732 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -1,3 +1,2 @@ add_subdirectory(lib) -add_subdirectory(hal) add_subdirectory(debug) diff --git a/ext/Kconfig b/ext/Kconfig index e85b0a35c9..5eb526c99c 100644 --- a/ext/Kconfig +++ b/ext/Kconfig @@ -5,8 +5,6 @@ menu "External Sources" -source "ext/hal/Kconfig" - source "ext/lib/crypto/Kconfig" source "ext/lib/fnmatch/Kconfig" diff --git a/ext/hal/CMakeLists.txt b/ext/hal/CMakeLists.txt deleted file mode 100644 index e0fee7003d..0000000000 --- a/ext/hal/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory_ifdef(CONFIG_HAS_ALTERA_HAL altera) diff --git a/ext/hal/Kconfig b/ext/hal/Kconfig deleted file mode 100644 index d6e5644a84..0000000000 --- a/ext/hal/Kconfig +++ /dev/null @@ -1,12 +0,0 @@ -# External HAL source code configuration options - -# Copyright (c) 2016-2017 Linaro Ltd. -# SPDX-License-Identifier: Apache-2.0 - -# When adding new entries keep the list in alphabetical order - -menu "HALs" - -source "ext/hal/altera/Kconfig" - -endmenu diff --git a/ext/hal/altera/CMakeLists.txt b/ext/hal/altera/CMakeLists.txt deleted file mode 100644 index 2a7f9949bc..0000000000 --- a/ext/hal/altera/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ - -#nios2 core/system level headers -zephyr_include_directories( - include - altera_hal/HAL/inc - ) - -zephyr_compile_definitions(ZEPHYR_RTOS) -add_subdirectory(altera_hal/HAL/src) - -if(CONFIG_ALTERA_AVALON_TIMER) - zephyr_include_directories( - drivers/altera_avalon_timer/inc - drivers/altera_avalon_timer/HAL/inc - ) - add_subdirectory(drivers/altera_avalon_timer/HAL/src) -endif() - -if(CONFIG_ALTERA_AVALON_SYSID) - zephyr_include_directories( - drivers/altera_avalon_sysid/inc - drivers/altera_avalon_sysid/HAL/inc - ) - add_subdirectory(drivers/altera_avalon_sysid/HAL/src) -endif() - -if(CONFIG_UART_ALTERA_JTAG) - zephyr_compile_definitions(ALTERA_AVALON_JTAG_UART_SMALL) - zephyr_include_directories( - drivers/altera_avalon_jtag_uart/inc - drivers/altera_avalon_jtag_uart/HAL/inc - drivers/altera_avalon_jtag_uart/LWHAL/inc - ) - add_subdirectory( - drivers/altera_avalon_jtag_uart/HAL/src - drivers/altera_avalon_jtag_uart/LWHAL/src - ) -endif() - -if(CONFIG_ALTERA_AVALON_MSGDMA) - zephyr_include_directories( - drivers/altera_msgdma/inc - drivers/altera_msgdma/HAL/inc - ) - add_subdirectory(drivers/altera_msgdma/HAL/src) -endif() - -if(CONFIG_ALTERA_AVALON_I2C) - zephyr_include_directories( - drivers/altera_avalon_i2c/inc - drivers/altera_avalon_i2c/HAL/inc - ) - add_subdirectory(drivers/altera_avalon_i2c/HAL/src) -endif() - -if(CONFIG_ALTERA_AVALON_QSPI) - zephyr_include_directories( - drivers/altera_generic_qspi_controller2/inc - drivers/altera_generic_qspi_controller2/HAL/inc - ) -endif() - diff --git a/ext/hal/altera/README b/ext/hal/altera/README deleted file mode 100644 index 16ad5bf636..0000000000 --- a/ext/hal/altera/README +++ /dev/null @@ -1,36 +0,0 @@ -Altera HAL -##################### - -Origin: - Altera Quartus Prime Lite SDK - http://dl.altera.com/?edition=lite - -Status: - v17.0 - -Purpose: - Hardware Abstraction Layer for NIOSII based soft IP blocks. - -Description: - Altera Hardware Abstraction Layer(or Altera HAL) provides the - low level driver support for NIOSII based soft IP blocks. - - Altera HAL primarily abstracts the low level hardware interactions - of different NIOSII based soft IP blocks like UART, I2C, SPI etc... - and provides the high level API's for the shim drivers. - -Dependencies: - Some of the Altera HAL drivers have dependency on the newlibc and - it needs to be enabled before enabling the Altera HAL. - - The NIOSII port of Zephyr will be accessing the Altera HAL through - shim drivers to enable the different soft IP blocks on Zephyr. - -URL: - https://www.altera.com/products/processors/support.html - -Maintained-by: - External - -License: - MIT diff --git a/ext/hal/altera/altera_hal/HAL/inc/altera_common.h b/ext/hal/altera/altera_hal/HAL/inc/altera_common.h deleted file mode 100644 index 5786309a18..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/altera_common.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef __ALT_COMMON_H__ -#define __ALT_COMMON_H__ - -#include "alt_types.h" - -extern void alt_handle_irq(void* base, alt_u32 id); - -#endif /* __ALT_COMMON_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/os/alt_flag.h b/ext/hal/altera/altera_hal/HAL/inc/os/alt_flag.h deleted file mode 100644 index 17d86974c7..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/os/alt_flag.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef __ALT_FLAG_H__ -#define __ALT_FLAG_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -/* - * This header provides macro definitions that can be used to create and use - * uc/OS-II style event flags. These macros can be used in both a uC/OS-II based - * environment, and a single threaded HAL based environment. - * - * The motivation for these macros is to allow code to be developed which is - * thread safe under uC/OS-II, but incurs no additional overhead when used in a - * single threaded HAL environment. - * - * In the case of a single threaded HAL environment, they compile to - * "do nothing" directives, which ensures they do not contribute to the final - * executable. - * - * The following macros are available: - * - * ALT_FLAG_GRP - Create a flag group instance. - * ALT_EXTERN_FLAG_GRP - Create a reference to an external flag group instance. - * ALT_STATIC_FLAG_GRP - Create a static flag group instance. - * ALT_FLAG_CREATE - Initialise a flag group. - * ALT_FLAG_PEND - Pend on a flag group. - * ALT_FLAG_POST - Set a flag condition. - - * - * Input arguments and return codes are all consistant with the equivalent - * uC/OS-II function. - * - * It's important to be careful in the use of the macros: ALT_FLAG_GRP, - * ALT_EXTERN_FLAG_GRP, and ALT_STATIC_FLAG_GRP. In these three cases the - * semi-colon is included in the macro definition; so, for example, you should - * use: - * - * ALT_FLAG_GRP(mygroup) - * - * not: - * - * ALT_FLAG_GRP(mygroup); - * - * The inclusion of the semi-colon has been necessary to ensure the macros can - * compile with no warnings when used in a single threaded HAL environment. - * - */ - -#include "priv/alt_no_error.h" - -#define ALT_FLAG_GRP(group) -#define ALT_EXTERN_FLAG_GRP(group) -#define ALT_STATIC_FLAG_GRP(group) - -#define ALT_FLAG_CREATE(group, flags) alt_no_error () -#define ALT_FLAG_PEND(group, flags, wait_type, timeout) alt_no_error () -#define ALT_FLAG_POST(group, flags, opt) alt_no_error () - -#ifndef ALT_SINGLE_THREADED -#define ALT_SINGLE_THREADED -#endif - -#endif /* __ALT_FLAG_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/os/alt_hooks.h b/ext/hal/altera/altera_hal/HAL/inc/os/alt_hooks.h deleted file mode 100644 index fe29be2aa1..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/os/alt_hooks.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __ALT_HOOKS_H__ -#define __ALT_HOOKS_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -/* - * This header provides "do-nothing" macro definitions for operating system - * hooks within the HAL. The O/S component can override these to provide it's - * own implementation. - */ - -#define ALT_OS_TIME_TICK() while(0) -#define ALT_OS_INIT() while(0) -#define ALT_OS_STOP() while(0) - -/* Call from assembly code */ -#define ALT_OS_INT_ENTER_ASM -#define ALT_OS_INT_EXIT_ASM - -/* Call from C code */ -#define ALT_OS_INT_ENTER() while(0) -#define ALT_OS_INT_EXIT() while(0) - - -#endif /* __ALT_HOOKS_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/os/alt_sem.h b/ext/hal/altera/altera_hal/HAL/inc/os/alt_sem.h deleted file mode 100644 index 0667fada7f..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/os/alt_sem.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef __ALT_SEM_H__ -#define __ALT_SEM_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -/* - * This header provides macro definitions that can be used to create and use - * semaphores. These macros can be used in both a uC/OS-II based environment, - * and a single threaded HAL based environment. - * - * The motivation for these macros is to allow code to be developed which is - * thread safe under uC/OS-II, but incurs no additional overhead when used in a - * single threaded HAL environment. - * - * In the case of a single threaded HAL environment, they compile to - * "do nothing" directives, which ensures they do not contribute to the final - * executable. - * - * The following macros are available: - * - * ALT_SEM - Create a semaphore instance. - * ALT_EXTERN_SEM - Create a reference to an external semaphore instance. - * ALT_STATIC_SEM - Create a static semaphore instance. - * ALT_SEM_CREATE - Initialise a semaphore. - * ALT_SEM_PEND - Pend on a semaphore. - * ALT_SEM_POST - Increment a semaphore. - * - * Input arguments and return codes are all consistant with the equivalent - * uC/OS-II function. - * - * It's important to be careful in the use of the macros: ALT_SEM, - * ALT_EXTERN_SEM, and ALT_STATIC_SEM. In these three cases the semi-colon is - * included in the macro definition; so, for example, you should use: - * - * ALT_SEM(mysem) - * - * not: - * - * ALT_SEM(mysem); - * - * The inclusion of the semi-colon has been necessary to ensure the macros can - * compile with no warnings when used in a single threaded HAL environment. - * - */ - -#include "priv/alt_no_error.h" - -#define ALT_SEM(sem) -#define ALT_EXTERN_SEM(sem) -#define ALT_STATIC_SEM(sem) - -#define ALT_SEM_CREATE(sem, value) alt_no_error () -#define ALT_SEM_PEND(sem, timeout) alt_no_error () -#define ALT_SEM_POST(sem) alt_no_error () - -#ifndef ALT_SINGLE_THREADED -#define ALT_SINGLE_THREADED -#endif - -#endif /* __ALT_SEM_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/os/alt_syscall.h b/ext/hal/altera/altera_hal/HAL/inc/os/alt_syscall.h deleted file mode 100644 index 018206d67c..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/os/alt_syscall.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef __ALT_SYSCALL_H__ -#define __ALT_SYSCALL_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/* - * The macros defined in this file are used to provide the function names used - * for the HAL 'UNIX style' interface, e.g. read(), write() etc. - * - * Operating systems which are ported to the HAL can provide their own - * version of this file, which will be used in preference. This allows - * the operating system to provide it's own implementation of the top level - * system calls, while retaining the HAL functions under a different name, - * for example, alt_read(), alt_write() etc. - */ - -#define ALT_CLOSE close -#define ALT_ENVIRON environ -#define ALT_EXECVE execve -#define ALT_EXIT _exit -#define ALT_FCNTL fcntl -#define ALT_FORK fork -#define ALT_FSTAT fstat -#define ALT_GETPID getpid -#define ALT_GETTIMEOFDAY gettimeofday -#define ALT_IOCTL ioctl -#define ALT_ISATTY isatty -#define ALT_KILL kill -#define ALT_LINK link -#define ALT_LSEEK lseek -#define ALT_OPEN open -#define ALT_READ read -#define ALT_RENAME _rename -#define ALT_SBRK sbrk -#define ALT_SETTIMEOFDAY settimeofday -#define ALT_STAT stat -#define ALT_UNLINK unlink -#define ALT_USLEEP usleep -#define ALT_WAIT wait -#define ALT_WRITE write -#define ALT_TIMES times - -/* - * - */ - -#endif /* __ALT_SYSCALL_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_alarm.h b/ext/hal/altera/altera_hal/HAL/inc/priv/alt_alarm.h deleted file mode 100644 index 78d7a19b07..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_alarm.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef __ALT_PRIV_ALARM_H__ -#define __ALT_PRIV_ALARM_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#include "alt_types.h" - -/* - * This header provides the internal defenitions required by the public - * interface alt_alarm.h. These variables and structures are not guaranteed to - * exist in future implementations of the HAL. - */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * "alt_alarm_s" is a structure type used to maintain lists of alarm callback - * functions. - */ - -struct alt_alarm_s -{ - alt_llist llist; /* linked list */ - alt_u32 time; /* time in system ticks of the callback */ - alt_u32 (*callback) (void* context); /* callback function. The return - * value is the period for the next callback; where - * zero indicates that the alarm should be removed - * from the list. - */ - alt_u8 rollover; /* set when desired alarm time + current time causes - overflow, to prevent premature alarm */ - void* context; /* Argument for the callback */ -}; - -/* - * "_alt_tick_rate" is a global variable used to store the system clock rate - * in ticks per second. This is initialised to zero, which coresponds to there - * being no system clock available. - * - * It is then set to it's final value by the system clock driver through a call - * to alt_sysclk_init(). - */ - -extern alt_u32 _alt_tick_rate; - -/* - * "_alt_nticks" is a global variable which records the elapsed number of - * system clock ticks since the last call to settimeofday() or since reset if - * settimeofday() has not been called. - */ - -extern volatile alt_u32 _alt_nticks; - -/* The list of registered alarms. */ - -extern alt_llist alt_alarm_list; - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_PRIV_ALARM_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_dev_llist.h b/ext/hal/altera/altera_hal/HAL/inc/priv/alt_dev_llist.h deleted file mode 100644 index 939dceabe9..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_dev_llist.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef __ALT_DEV_LLIST_H__ -#define __ALT_DEV_LLIST_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#include "sys/alt_llist.h" -#include "alt_types.h" - -/* - * This header provides the internal defenitions required to control file - * access. These variables and functions are not guaranteed to exist in - * future implementations of the HAL. - */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * The alt_dev_llist is an internal structure used to form a common base - * class for all device types. The use of this structure allows common code - * to be used to manipulate the various device lists. - */ - -typedef struct { - alt_llist llist; - const char* name; -} alt_dev_llist; - -/* - * - */ - -extern int alt_dev_llist_insert (alt_dev_llist* dev, alt_llist* list); - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_DEV_LLIST_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_exception_handler_registry.h b/ext/hal/altera/altera_hal/HAL/inc/priv/alt_exception_handler_registry.h deleted file mode 100644 index eb313771c8..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_exception_handler_registry.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __ALT_EXCEPTION_HANDLER_REGISTRY_H__ -#define __ALT_EXCEPTION_HANDLER_REGISTRY_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2008 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ -#include "sys/alt_exceptions.h" - -/* Function pointer to exception callback routine */ -extern alt_exception_result (*alt_instruction_exception_handler) - (alt_exception_cause, alt_u32, alt_u32); - -#endif /* __ALT_EXCEPTION_HANDLER_REGISTRY_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_file.h b/ext/hal/altera/altera_hal/HAL/inc/priv/alt_file.h deleted file mode 100644 index bdf7ad4e4a..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_file.h +++ /dev/null @@ -1,177 +0,0 @@ -#ifndef __ALT_FILE_H__ -#define __ALT_FILE_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#include "sys/alt_dev.h" -#include "sys/alt_llist.h" -#include "os/alt_sem.h" - -#include "alt_types.h" - -/* - * This header provides the internal defenitions required to control file - * access. These variables and functions are not guaranteed to exist in - * future implementations of the HAL. - */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * The function alt_find_dev() is used to search the device list "list" to - * locate a device named "name". If a match is found, then a pointer to the - * device is returned, otherwise NULL is returned. - */ - -extern alt_dev* alt_find_dev (const char* name, alt_llist* list); - -/* - * alt_find_file() is used to search the list of registered file systems to - * find the filesystem that the file named "name" belongs to. If a match is - * found, then a pointer to the filesystems alt_dev structure is returned, - * otherwise NULL is returned. - * - * Note that a match does not indicate that the file exists, only that a - * filesystem exists that is registered for a partition that could contain - * the file. The filesystems open() function would need to be called in order - * to determine if the file exists. - */ - -extern alt_dev* alt_find_file (const char* name); - -/* - * alt_get_fd() is used to allocate a file descriptor for the device or - * filesystem "dev". A negative return value indicates an error, otherwise the - * return value is the index of the file descriptor within the file descriptor - * pool. - */ - -extern int alt_get_fd (alt_dev* dev); - -/* - * alt_release_fd() is called to free the file descriptor with index "fd". - */ - -extern void alt_release_fd (int fd); - -/* - * alt_fd_lock() is called by ioctl() to mark the file descriptor "fd" as - * being open for exclusive access. Subsequent calls to open() for the device - * associated with "fd" will fail. A device is unlocked by either calling - * close() for "fd", or by an alternate call to ioctl() (see ioctl.c for - * details). - */ - -extern int alt_fd_lock (alt_fd* fd); - -/* - * alt_fd_unlock() is called by ioctl() to unlock a descriptor previously - * locked by a call to alt_fd_lock(). - */ - -extern int alt_fd_unlock (alt_fd* fd); - -/* - * "alt_fd_list" is the pool of file descriptors. - */ - -extern alt_fd alt_fd_list[]; - -/* - * flags used by alt_fd. - * - * ALT_FD_EXCL is used to mark a file descriptor as locked for exclusive - * access, i.e. further calls to open() for the associated device should - * fail. - * - * ALT_FD_DEV marks a dile descriptor as belonging to a device as oposed to a - * filesystem. - */ - -#define ALT_FD_EXCL 0x80000000 -#define ALT_FD_DEV 0x40000000 - -#define ALT_FD_FLAGS_MASK (ALT_FD_EXCL | ALT_FD_DEV) - -/* - * "alt_dev_list" is the head of the linked list of registered devices. - */ - -extern alt_llist alt_dev_list; - -/* - * "alt_fs_list" is the head of the linked list of registered filesystems. - */ - -extern alt_llist alt_fs_list; - -/* - * "alt_fd_list_lock" is a semaphore used to ensure that access to the pool - * of file descriptors is thread safe. - */ - -ALT_EXTERN_SEM(alt_fd_list_lock) - -/* - * "alt_max_fd" is a 'high water mark'. It indicates the highest file - * descriptor allocated. Use of this can save searching the entire pool - * for active file descriptors, which helps avoid contention on access - * to the file descriptor pool. - */ - -extern alt_32 alt_max_fd; - -/* - * alt_io_redirect() is called at startup to redirect stdout, stdin, and - * stderr to the devices named in the input arguments. By default these streams - * are directed at /dev/null, and are then redirected using this function once - * all of the devices have been registered within the system. - */ - -extern void alt_io_redirect(const char* stdout_dev, - const char* stdin_dev, - const char* stderr_dev); - - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_FILE_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_iic_isr_register.h b/ext/hal/altera/altera_hal/HAL/inc/priv/alt_iic_isr_register.h deleted file mode 100644 index 766c2ebff1..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_iic_isr_register.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __ALT_IIC_ISR_REGISTER_H_ -#define __ALT_IIC_ISR_REGISTER_H_ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ -#include "alt_types.h" -#include "sys/alt_irq.h" - -extern int alt_iic_isr_register(alt_u32 ic_id, alt_u32 irq, alt_isr_func isr, - void *isr_context, void *flags); - -#endif /* __ALT_IIC_ISR_REGISTER_H_ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_irq_table.h b/ext/hal/altera/altera_hal/HAL/inc/priv/alt_irq_table.h deleted file mode 100644 index bf8f308aa3..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_irq_table.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __ALT_IRQ_TABLE_H__ -#define __ALT_IRQ_TABLE_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -/* - * Definition of a table describing each interrupt handler. The index into - * the array is the interrupt id associated with the handler. - * - * When an interrupt occurs, the associated handler is called with - * the argument stored in the context member. - * - * The table is physically created in alt_irq_handler.c - */ -extern struct ALT_IRQ_HANDLER -{ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT - void (*handler)(void*); -#else - void (*handler)(void*, alt_u32); -#endif - void *context; -} alt_irq[ALT_NIRQ]; - -#endif diff --git a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_no_error.h b/ext/hal/altera/altera_hal/HAL/inc/priv/alt_no_error.h deleted file mode 100644 index 33768e3466..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/priv/alt_no_error.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef __ALT_NO_ERROR_H__ -#define __ALT_NO_ERROR_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#include "alt_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * alt_no_error() is a dummy function used by alt_sem.h and alt_flag.h. It - * substitutes for functions that have a return code by creating a function - * that always returns zero. - * - * This may seem a little obscure, but what happens is that the compiler can - * then optomise away the call to this function, and any code written which - * handles the error path (i.e. non zero return values). - * - * This allows code to be written which correctly use the uC/OS-II semaphore - * and flag utilities, without the use of those utilities impacting on - * excutables built for a single threaded HAL environment. - * - * This function is considered to be part of the internal implementation of - * the HAL, and should not be called directly by application code or device - * drivers. It is not guaranteed to be preserved in future versions of the - * HAL. - */ - -static ALT_INLINE int ALT_ALWAYS_INLINE alt_no_error (void) -{ - return 0; -} - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_NO_ERROR_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_alarm.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_alarm.h deleted file mode 100644 index a3a2ef7f5a..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_alarm.h +++ /dev/null @@ -1,161 +0,0 @@ -#ifndef __ALT_ALARM_H__ -#define __ALT_ALARM_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#include "alt_llist.h" -#include "alt_types.h" - -#include "priv/alt_alarm.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * "alt_alarm" is a structure type used by applications to register an alarm - * callback function. An instance of this type must be passed as an input - * argument to alt_alarm_start(). The user is not responsible for initialising - * the contents of the instance. This is done by alt_alarm_start(). - */ - -typedef struct alt_alarm_s alt_alarm; - -/* - * alt_alarm_start() can be called by an application/driver in order to register - * a function for periodic callback at the system clock frequency. Be aware that - * this callback is likely to occur in interrupt context. - */ - -extern int alt_alarm_start (alt_alarm* the_alarm, - alt_u32 nticks, - alt_u32 (*callback) (void* context), - void* context); - -/* - * alt_alarm_stop() is used to unregister a callback. Alternatively the callback - * can return zero to unregister. - */ - -extern void alt_alarm_stop (alt_alarm* the_alarm); - -#ifndef ZEPHYR_RTOS -/* - * Obtain the system clock rate in ticks/s. - */ - -static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_ticks_per_second (void) -{ - return _alt_tick_rate; -} - -/* - * alt_sysclk_init() is intended to be only used by the system clock driver - * in order to initialise the value of the clock frequency. - */ - -static ALT_INLINE int ALT_ALWAYS_INLINE alt_sysclk_init (alt_u32 nticks) -{ - if (! _alt_tick_rate) - { - _alt_tick_rate = nticks; - return 0; - } - else - { - return -1; - } -} - -/* - * alt_nticks() returns the elapsed number of system clock ticks since reset. - */ - -static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_nticks (void) -{ - return _alt_nticks; -} - -/* - * alt_tick() should only be called by the system clock driver. This is used - * to notify the system that the system timer period has expired. - */ - -extern void alt_tick (void); -#else -/* - * Obtain the system clock rate in ticks/s. - */ - -static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_ticks_per_second (void) -{ - return 0; -} - -/* - * alt_sysclk_init() is intended to be only used by the system clock driver - * in order to initialise the value of the clock frequency. - */ - -static ALT_INLINE int ALT_ALWAYS_INLINE alt_sysclk_init (alt_u32 nticks) -{ - return 0; -} - -/* - * alt_nticks() returns the elapsed number of system clock ticks since reset. - */ - -static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_nticks (void) -{ - return 0; -} - -/* - * alt_tick() should only be called by the system clock driver. This is used - * to notify the system that the system timer period has expired. - */ - -extern void alt_tick (void); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_ALARM_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_cache.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_cache.h deleted file mode 100644 index a13c12be8f..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_cache.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef __ALT_CACHE_H__ -#define __ALT_CACHE_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003, 2007 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include - -#include "alt_types.h" - -/* - * alt_cache.h defines the processor specific functions for manipulating the - * cache. - */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * alt_icache_flush() is called to flush the instruction cache for a memory - * region of length "len" bytes, starting at address "start". - */ - -extern void alt_icache_flush (void* start, alt_u32 len); - -/* - * alt_dcache_flush() is called to flush the data cache for a memory - * region of length "len" bytes, starting at address "start". - * Any dirty lines in the data cache are written back to memory. - */ - -extern void alt_dcache_flush (void* start, alt_u32 len); - -/* - * alt_dcache_flush() is called to flush the data cache for a memory - * region of length "len" bytes, starting at address "start". - * Any dirty lines in the data cache are NOT written back to memory. - */ - -extern void alt_dcache_flush_no_writeback (void* start, alt_u32 len); - -/* - * Flush the entire instruction cache. - */ - -extern void alt_icache_flush_all (void); - -/* - * Flush the entire data cache. - */ - -extern void alt_dcache_flush_all (void); - -/* - * Allocate a block of uncached memory. - */ - -extern volatile void* alt_uncached_malloc (size_t size); - -/* - * Free a block of uncached memory. - */ - -extern void alt_uncached_free (volatile void* ptr); - -/* - * Convert a pointer to a block of cached memory, into a block of - * uncached memory. - */ - -extern volatile void* alt_remap_uncached (void* ptr, alt_u32 len); - -/* - * Convert a pointer to a block of uncached memory, into a block of - * cached memory. - */ - -extern void* alt_remap_cached (volatile void* ptr, alt_u32 len); - -/* - * - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_CACHE_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_dev.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_dev.h deleted file mode 100644 index cc0b859296..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_dev.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef __ALT_DEV_H__ -#define __ALT_DEV_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#include "system.h" -#include "sys/alt_llist.h" -#include "priv/alt_dev_llist.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * The value ALT_IRQ_NOT_CONNECTED is used to represent an unconnected - * interrupt line. It cannot evaluate to a valid interrupt number. - */ - -#define ALT_IRQ_NOT_CONNECTED (-1) - -typedef struct alt_dev_s alt_dev; - -struct stat; - -/* - * The file descriptor structure definition. - */ - -typedef struct alt_fd_s -{ - alt_dev* dev; - alt_u8* priv; - int fd_flags; -} alt_fd; - -/* - * The device structure definition. - */ - -struct alt_dev_s { - alt_llist llist; /* for internal use */ - const char* name; - int (*open) (alt_fd* fd, const char* name, int flags, int mode); - int (*close) (alt_fd* fd); - int (*read) (alt_fd* fd, char* ptr, int len); - int (*write) (alt_fd* fd, const char* ptr, int len); - int (*lseek) (alt_fd* fd, int ptr, int dir); - int (*fstat) (alt_fd* fd, struct stat* buf); - int (*ioctl) (alt_fd* fd, int req, void* arg); -}; - -/* - * Functions used to register device for access through the C standard - * library. - * - * The only difference between alt_dev_reg() and alt_fs_reg() is the - * interpretation that open() places on the device name. In the case of - * alt_dev_reg the device is assumed to be a particular character device, - * and so there must be an exact match in the name for open to succeed. - * In the case of alt_fs_reg() the name of the device is treated as the - * mount point for a directory, and so any call to open() where the name - * is the root of the device filename will succeed. - */ - -extern int alt_fs_reg (alt_dev* dev); - -static ALT_INLINE int alt_dev_reg (alt_dev* dev) -{ - extern alt_llist alt_dev_list; - - return alt_dev_llist_insert ((alt_dev_llist*) dev, &alt_dev_list); -} - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_DEV_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_dma.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_dma.h deleted file mode 100644 index bcc5355faa..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_dma.h +++ /dev/null @@ -1,224 +0,0 @@ -#ifndef __ALT_DMA_H__ -#define __ALT_DMA_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004-2005 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#include "sys/alt_dma_dev.h" -#include "alt_types.h" - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * This header contains the application side interface for accessing DMA - * resources. See alt_dma_dev.h for the dma device driver interface. - * - * The interface model treats a DMA transaction as being composed of two - * halves (read and write). - * - * The application can supply data for transmit using an "alt_dma_txchan" - * descriptor. Alternatively an "alt_dma_rxchan" descriptor can be used to - * receive data. - */ - -/* - * alt_dma_txchan_open() is used to obtain an "alt_dma_txchan" descriptor for - * a DMA transmit device. The name is the name of the associated physical - * device (e.g. "/dev/dma_0"). - * - * The return value will be NULL on failure, and non-NULL otherwise. - */ - -extern alt_dma_txchan alt_dma_txchan_open (const char* name); - -/* - * alt_dma_txchan_close() is provided so that an application can notify the - * system that it has finished with a given DMA transmit channel. This is only - * provided for completness. - */ - -static ALT_INLINE int alt_dma_txchan_close (alt_dma_txchan dma) -{ - return 0; -} - -/* - * alt_dma_txchan_send() posts a transmit request to a DMA transmit channel. - * The input arguments are: - * - * dma: the channel to use. - * from: a pointer to the start of the data to send. - * length: the length of the data to send in bytes. - * done: callback function that will be called once the data has been sent. - * handle: opaque value passed to "done". - * - * The return value will be negative if the request cannot be posted, and - * zero otherwise. - */ - -static ALT_INLINE int alt_dma_txchan_send (alt_dma_txchan dma, - const void* from, - alt_u32 length, - alt_txchan_done* done, - void* handle) -{ - return dma ? dma->dma_send (dma, - from, - length, - done, - handle) : -ENODEV; -} - -/* - * alt_dma_txchan_space() returns the number of tranmit requests that can be - * posted to the specified DMA transmit channel. - * - * A negative value indicates that the value could not be determined. - */ - -static ALT_INLINE int alt_dma_txchan_space (alt_dma_txchan dma) -{ - return dma ? dma->space (dma) : -ENODEV; -} - -/* - * alt_dma_txchan_ioctl() can be used to perform device specific I/O - * operations on the indicated DMA transmit channel. For example some drivers - * support options to control the width of the transfer operations. See - * alt_dma_dev.h for the list of generic requests. - * - * A negative return value indicates failure, otherwise the interpretation - * of the return value is request specific. - */ - -static ALT_INLINE int alt_dma_txchan_ioctl (alt_dma_txchan dma, - int req, - void* arg) -{ - return dma ? dma->ioctl (dma, req, arg) : -ENODEV; -} - -/* - * alt_dma_rxchan_open() is used to obtain an "alt_dma_rxchan" descriptor for - * a DMA receive channel. The name is the name of the associated physical - * device (e.g. "/dev/dma_0"). - * - * The return value will be NULL on failure, and non-NULL otherwise. - */ - -extern alt_dma_rxchan alt_dma_rxchan_open (const char* dev); - -/* - * alt_dma_rxchan_close() is provided so that an application can notify the - * system that it has finished with a given DMA receive channel. This is only - * provided for completness. - */ - -static ALT_INLINE int alt_dma_rxchan_close (alt_dma_rxchan dma) -{ - return 0; -} - -/* - * - */ - -/* - * alt_dma_rxchan_prepare() posts a receive request to a DMA receive channel. - * - * The input arguments are: - * - * dma: the channel to use. - * data: a pointer to the location that data is to be received to. - * len: the maximum length of the data to receive. - * done: callback function that will be called once the data has been - * received. - * handle: opaque value passed to "done". - * - * The return value will be negative if the request cannot be posted, and - * zero otherwise. - */ - -static ALT_INLINE int alt_dma_rxchan_prepare (alt_dma_rxchan dma, - void* data, - alt_u32 len, - alt_rxchan_done* done, - void* handle) -{ - return dma ? dma->prepare (dma, data, len, done, handle) : -ENODEV; -} - -/* - * alt_dma_rxchan_ioctl() can be used to perform device specific I/O - * operations on the indicated DMA receive channel. For example some drivers - * support options to control the width of the transfer operations. See - * alt_dma_dev.h for the list of generic requests. - * - * A negative return value indicates failure, otherwise the interpretation - * of the return value is request specific. - */ - -static ALT_INLINE int alt_dma_rxchan_ioctl (alt_dma_rxchan dma, - int req, - void* arg) -{ - return dma ? dma->ioctl (dma, req, arg) : -ENODEV; -} - -/* - * alt_dma_rxchan_depth() returns the depth of the receive FIFO used to store - * receive requests. - */ - -static ALT_INLINE alt_u32 alt_dma_rxchan_depth(alt_dma_rxchan dma) -{ - return dma->depth; -} - -/* - * - */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_DMA_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_dma_dev.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_dma_dev.h deleted file mode 100644 index 0b278dfff8..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_dma_dev.h +++ /dev/null @@ -1,198 +0,0 @@ -#ifndef __ALT_DMA_DEV_H__ -#define __ALT_DMA_DEV_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004-2005 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#include "priv/alt_dev_llist.h" - -#include "alt_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * This header contains the device driver interface for accessing DMA - * resources. See alt_dma.h for the DMA application side interface. - * - * The interface model treats a DMA transaction as being composed of two - * halves (read and write). - * - * An "alt_dma_txchan_dev" is used to describe the device associated with a - * DMA transmit channel. An "alt_dma_rxchan_dev" is used to describe the - * device associated with a DMA receive channel. - */ - -/* - * List of generic ioctl requests that may be supported by a DMA device. - * - * ALT_DMA_RX_ONLY_ON: This causes a DMA channel to operate in a mode - * where only the receiver is under software control. - * The other side reads continously from a single - * location. The address to read is the argument to - * this request. - * ALT_DMA_RX_ONLY_OFF: Return to the default mode where both the receive - * and transmit sides of the DMA can be under software - * control. - * ALT_DMA_TX_ONLY_ON: This causes a DMA channel to operate in a mode - * where only the transmitter is under software control. - * The other side writes continously to a single - * location. The address to write to is the argument to - * this request. - * ALT_DMA_TX_ONLY_OFF: Return to the default mode where both the receive - * and transmit sides of the DMA can be under software - * control. - * ALT_DMA_SET_MODE_8: Transfer data in units of 8 bits. - * ALT_DMA_SET_MODE_16: Transfer data in units of 16 bits. - * ALT_DMA_SET_MODE_32: Transfer data in units of 32 bits. - * ALT_DMA_SET_MODE_64: Transfer data in units of 64 bits. - * ALT_DMA_SET_MODE_128: Transfer data in units of 128 bits. - * ALT_DMA_GET_MODE: Get the current transfer mode. - * - * The use of the macros: ALT_DMA_TX_STREAM_ON, ALT_DMA_TX_STREAM_OFF - * ALT_DMA_RX_STREAM_OFF and ALT_DMA_RX_STREAM_ON are depreciated. You should - * instead use the macros: ALT_DMA_RX_ONLY_ON, ALT_DMA_RX_ONLY_OFF, - * ALT_DMA_TX_ONLY_ON and ALT_DMA_TX_ONLY_OFF. - */ - -#define ALT_DMA_TX_STREAM_ON (0x1) -#define ALT_DMA_TX_STREAM_OFF (0x2) -#define ALT_DMA_RX_STREAM_ON (0x3) -#define ALT_DMA_RX_STREAM_OFF (0x4) -#define ALT_DMA_SET_MODE_8 (0x5) -#define ALT_DMA_SET_MODE_16 (0x6) -#define ALT_DMA_SET_MODE_32 (0x7) -#define ALT_DMA_SET_MODE_64 (0x8) -#define ALT_DMA_SET_MODE_128 (0x9) -#define ALT_DMA_GET_MODE (0xa) - -#define ALT_DMA_RX_ONLY_ON ALT_DMA_TX_STREAM_ON -#define ALT_DMA_RX_ONLY_OFF ALT_DMA_TX_STREAM_OFF -#define ALT_DMA_TX_ONLY_ON ALT_DMA_RX_STREAM_ON -#define ALT_DMA_TX_ONLY_OFF ALT_DMA_RX_STREAM_OFF - -/* - * - */ - -typedef struct alt_dma_txchan_dev_s alt_dma_txchan_dev; -typedef struct alt_dma_rxchan_dev_s alt_dma_rxchan_dev; - -typedef alt_dma_txchan_dev* alt_dma_txchan; -typedef alt_dma_rxchan_dev* alt_dma_rxchan; - -typedef void (alt_txchan_done)(void* handle); -typedef void (alt_rxchan_done)(void* handle, void* data); - -/* - * devices that provide a DMA transmit channel are required to provide an - * instance of the "alt_dma_txchan_dev" structure. - */ - -struct alt_dma_txchan_dev_s { - alt_llist llist; /* for internal use */ - const char* name; /* name of the device instance - * (e.g. "/dev/dma_0"). - */ - int (*space) (alt_dma_txchan dma); /* returns the maximum number of - * transmit requests that can be posted - */ - int (*dma_send) (alt_dma_txchan dma, - const void* from, - alt_u32 len, - alt_txchan_done* done, - void* handle); /* post a transmit request */ - int (*ioctl) (alt_dma_txchan dma, int req, void* arg); /* perform device - * specific I/O control. - */ -}; - -/* - * devices that provide a DMA receive channel are required to provide an - * instance of the "alt_dma_rxchan_dev" structure. - */ - -struct alt_dma_rxchan_dev_s { - alt_llist list; /* for internal use */ - const char* name; /* name of the device instance - * (e.g. "/dev/dma_0"). - */ - alt_u32 depth; /* maximum number of receive requests that - * can be posted. - */ - int (*prepare) (alt_dma_rxchan dma, - void* data, - alt_u32 len, - alt_rxchan_done* done, - void* handle); /* post a receive request */ - int (*ioctl) (alt_dma_rxchan dma, int req, void* arg); /* perform device - * specific I/O control. - */ -}; - -/* - * Register a DMA transmit channel with the system. - */ - -static ALT_INLINE int alt_dma_txchan_reg (alt_dma_txchan_dev* dev) -{ - extern alt_llist alt_dma_txchan_list; - - return alt_dev_llist_insert((alt_dev_llist*) dev, &alt_dma_txchan_list); -} - -/* - * Register a DMA receive channel with the system. - */ - -static ALT_INLINE int alt_dma_rxchan_reg (alt_dma_rxchan_dev* dev) -{ - extern alt_llist alt_dma_rxchan_list; - - return alt_dev_llist_insert((alt_dev_llist*) dev, &alt_dma_rxchan_list); -} - -/* - * - */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_DMA_DEV_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_driver.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_driver.h deleted file mode 100644 index 91cb62894f..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_driver.h +++ /dev/null @@ -1,166 +0,0 @@ -#ifndef __ALT_DRIVER_H__ -#define __ALT_DRIVER_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/* - * Macros used to access a driver without HAL file descriptors. - */ - -/* - * ALT_MODULE_CLASS - * - * This macro returns the module class name for the specified module instance. - * It uses information in the system.h file. - * Neither the instance name or class name are quoted (so that they can - * be used with other pre-processor macros). - * - * Example: - * Assume the design has an instance of an altera_avalon_uart called uart1. - * Calling ALT_MODULE_CLASS(uart1) returns altera_avalon_uart. - */ - -#define ALT_MODULE_CLASS(instance) ALT_MODULE_CLASS_ ## instance - - -/* - * ALT_DRIVER_FUNC_NAME - * - * --> instance Instance name. - * --> func Function name. - * - * This macro returns the device driver function name of the specified - * module instance for the specified function name. - * - * Example: - * Assume the design has an instance of an altera_avalon_uart called uart1. - * Calling ALT_DRIVER_FUNC_NAME(uart1, write) returns - * altera_avalon_uart_write. - */ - -#define ALT_DRIVER_FUNC_NAME(instance, func) \ - ALT_DRIVER_FUNC_NAME1(ALT_MODULE_CLASS(instance), func) -#define ALT_DRIVER_FUNC_NAME1(module_class, func) \ - ALT_DRIVER_FUNC_NAME2(module_class, func) -#define ALT_DRIVER_FUNC_NAME2(module_class, func) \ - module_class ## _ ## func - -/* - * ALT_DRIVER_STATE_STRUCT - * - * --> instance Instance name. - * - * This macro returns the device driver state type name of the specified - * module instance. - * - * Example: - * Assume the design has an instance of an altera_avalon_uart called uart1. - * Calling ALT_DRIVER_STATE_STRUCT(uart1) returns: - * struct altera_avalon_uart_state_s - * - * Note that the ALT_DRIVER_FUNC_NAME macro is used even though "state" isn't - * really a function but it does match the required naming convention. - */ -#define ALT_DRIVER_STATE_STRUCT(instance) \ - struct ALT_DRIVER_FUNC_NAME(instance, state_s) - -/* - * ALT_DRIVER_STATE - * - * --> instance Instance name. - * - * This macro returns the device driver state name of the specified - * module instance. - * - * Example: - * Assume the design has an instance of an altera_avalon_uart called uart1. - * Calling ALT_DRIVER_STATE(uart1) returns uart1. - */ -#define ALT_DRIVER_STATE(instance) instance - -/* - * ALT_DRIVER_WRITE - * - * --> instance Instance name. - * --> buffer Write buffer. - * --> len Length of write buffer data. - * --> flags Control flags (e.g. O_NONBLOCK) - * - * This macro calls the "write" function of the specified driver instance. - */ - -#define ALT_DRIVER_WRITE_EXTERNS(instance) \ - extern ALT_DRIVER_STATE_STRUCT(instance) ALT_DRIVER_STATE(instance); \ - extern int ALT_DRIVER_FUNC_NAME(instance, write) \ - (ALT_DRIVER_STATE_STRUCT(instance) *, const char *, int, int); - -#define ALT_DRIVER_WRITE(instance, buffer, len, flags) \ - ALT_DRIVER_FUNC_NAME(instance, write)(&ALT_DRIVER_STATE(instance), buffer, len, flags) - - -/* - * ALT_DRIVER_READ - * - * --> instance Instance name. - * <-- buffer Read buffer. - * --> len Length of read buffer. - * --> flags Control flags (e.g. O_NONBLOCK) - * - * This macro calls the "read" function of the specified driver instance. - */ - -#define ALT_DRIVER_READ_EXTERNS(instance) \ - extern ALT_DRIVER_STATE_STRUCT(instance) ALT_DRIVER_STATE(instance); \ - extern int ALT_DRIVER_FUNC_NAME(instance, read) \ - (ALT_DRIVER_STATE_STRUCT(instance) *, const char *, int, int); - -#define ALT_DRIVER_READ(instance, buffer, len, flags) \ - ALT_DRIVER_FUNC_NAME(instance, read)(&ALT_DRIVER_STATE(instance), buffer, len, flags) - -/* - * ALT_DRIVER_IOCTL - * - * --> instance Instance name. - * --> req ioctl request (e.g. TIOCSTIMEOUT) - * --> arg Optional argument (void*) - * - * This macro calls the "ioctl" function of the specified driver instance - */ - -#define ALT_DRIVER_IOCTL_EXTERNS(instance) \ - extern ALT_DRIVER_STATE_STRUCT(instance) ALT_DRIVER_STATE(instance); \ - extern int ALT_DRIVER_FUNC_NAME(instance, ioctl) \ - (ALT_DRIVER_STATE_STRUCT(instance) *, int, void*); - -#define ALT_DRIVER_IOCTL(instance, req, arg) \ - ALT_DRIVER_FUNC_NAME(instance, ioctl)(&ALT_DRIVER_STATE(instance), req, arg) - -#endif /* __ALT_DRIVER_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_errno.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_errno.h deleted file mode 100644 index 88a3db3ee9..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_errno.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef __ALT_ERRNO_H__ -#define __ALT_ERRNO_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -/* - * errno is defined in so that it uses the thread local version - * stored in the location pointed to by "_impure_ptr". This means that the - * accesses to errno within the HAL library can cause the entirety of - * of the structure pointed to by "_impure_ptr" to be added to the - * users application. This can be undesirable in very small footprint systems. - * - * To avoid this happening, the HAL uses the macro ALT_ERRNO, defined below, - * to access errno, rather than accessing it directly. This macro will only - * use the thread local version if some other code has already caused it to be - * included into the system, otherwise it will use the global errno value. - * - * This causes a slight increases in code size where errno is accessed, but - * can lead to significant overall benefits in very small systems. The - * increase is inconsequential when compared to the size of the structure - * pointed to by _impure_ptr. - * - * Note that this macro accesses __errno() using an externally declared - * function pointer (alt_errno). This is done so that the function call uses the - * subroutine call instruction via a register rather than an immediate address. - * This is important in the case that the code has been linked for a high - * address, but __errno() is not being used. In this case the weak linkage - * would have resulted in the instruction: "call 0" which would fail to link. - */ - -extern int* (*alt_errno) (void); - -/* Must define this so that values such as EBADFD are defined in errno.h. */ -#ifndef __LINUX_ERRNO_EXTENSIONS__ -#define __LINUX_ERRNO_EXTENSIONS__ -#endif - -#include - -#include "alt_types.h" - -#undef errno - -extern int errno; - -static ALT_INLINE int* alt_get_errno(void) -{ - return ((alt_errno) ? alt_errno() : &errno); -} - -#define ALT_ERRNO *alt_get_errno() - -#endif /* __ALT_ERRNO_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_flash.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_flash.h deleted file mode 100644 index 0d4eaf0292..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_flash.h +++ /dev/null @@ -1,179 +0,0 @@ -#ifndef __ALT_FLASH_H__ -#define __ALT_FLASH_H__ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2015 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -/****************************************************************************** -* * -* Alt_flash.h - User interface for flash code * -* * -* Use this interface to avoid being exposed to the internals of the device * -* driver architecture. If you chose to use the flash driver internal * -* structures we don't guarantee not to change them * -* * -* Author PRR * -* * -******************************************************************************/ - - - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include "alt_types.h" -#include "alt_flash_types.h" -#include "alt_flash_dev.h" -#include "sys/alt_cache.h" - -alt_flash_fd* alt_flash_open_dev(const char* name); -void alt_flash_close_dev(alt_flash_fd* fd ); - -/* - * alt_flash_lock - * - * Locks the range of the memory sectors, which - * protected from write and erase. - * - */ -static __inline__ int __attribute__ ((always_inline)) alt_lock_flash( - alt_flash_fd* fd, alt_u32 sectors_to_lock) -{ - return fd->lock( fd, sectors_to_lock); -} - -/* - * alt_write_flash - * - * Program a buffer into flash. - * - * This routine erases all the affected erase blocks (if necessary) - * and then programs the data. However it does not read the data out first - * and preserve and none overwritten data, because this would require very - * large buffers on the target. If you need - * that functionality use the functions below. - */ -static __inline__ int __attribute__ ((always_inline)) alt_write_flash( - alt_flash_fd* fd, - int offset, - const void* src_addr, - int length ) -{ - return fd->write( fd, offset, src_addr, length ); -} - -/* - * alt_read_flash - * - * Read a block of flash for most flashes this is just memcpy - * it's here for completeness in case we need it for some serial flash device - * - */ -static __inline__ int __attribute__ ((always_inline)) alt_read_flash( - alt_flash_fd* fd, int offset, - void* dest_addr, int length ) -{ - return fd->read( fd, offset, dest_addr, length ); -} - -/* - * alt_get_flash_info - * - * Return the information on the flash sectors. - * - */ -static __inline__ int __attribute__ ((always_inline)) alt_get_flash_info( - alt_flash_fd* fd, flash_region** info, - int* number_of_regions) -{ - return fd->get_info( fd, info, number_of_regions); -} - -/* - * alt_erase_flash_block - * - * Erase a particular erase block, pass in the offset to the start of - * the block and it's size - */ -static __inline__ int __attribute__ ((always_inline)) alt_erase_flash_block( - alt_flash_fd* fd, int offset, int length) -{ - int ret_code; - ret_code = fd->erase_block( fd, offset ); - -/* remove dcache_flush call for FB330552 - if(!ret_code) - alt_dcache_flush((alt_u8*)fd->base_addr + offset, length); -*/ - return ret_code; -} - -/* - * alt_write_flash_block - * - * Write a particular flash block, block_offset is the offset - * (from the base of flash) to start of the block - * data_offset is the offset (from the base of flash) - * where you wish to start programming - * - * NB this function DOES NOT check that you are only writing a single - * block of data as that would slow down this function. - * - * Use alt_write_flash if you want that level of error checking. - */ - -static __inline__ int __attribute__ ((always_inline)) alt_write_flash_block( - alt_flash_fd* fd, int block_offset, - int data_offset, - const void *data, int length) -{ - - int ret_code; - ret_code = fd->write_block( fd, block_offset, data_offset, data, length ); - -/* remove dcache_flush call for FB330552 - if(!ret_code) - alt_dcache_flush((alt_u8*)fd->base_addr + data_offset, length); -*/ - return ret_code; -} - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_FLASH_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_flash_dev.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_flash_dev.h deleted file mode 100644 index a0543e75d8..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_flash_dev.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __ALT_FLASH_DEV_H__ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2015 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -/****************************************************************************** -* * -* Alt_flash_dev.h - Generic Flash device interfaces * -* * -* Author PRR * -* * -******************************************************************************/ -#define __ALT_FLASH_DEV_H__ - -#include "alt_flash_types.h" -#include "sys/alt_llist.h" -#include "priv/alt_dev_llist.h" - -#include "alt_types.h" - -typedef struct alt_flash_dev alt_flash_dev; -typedef alt_flash_dev alt_flash_fd; - -static ALT_INLINE int alt_flash_device_register( alt_flash_fd* fd) -{ - extern alt_llist alt_flash_dev_list; - - return alt_dev_llist_insert ((alt_dev_llist*) fd, &alt_flash_dev_list); -} - -typedef alt_flash_dev* (*alt_flash_open)(alt_flash_dev* flash, - const char* name ); -typedef int (*alt_flash_close)(alt_flash_dev* flash_info); - -typedef int (*alt_flash_write)( alt_flash_dev* flash, int offset, - const void* src_addr, int length ); - -typedef int (*alt_flash_get_flash_info)( alt_flash_dev* flash, flash_region** info, - int* number_of_regions); -typedef int (*alt_flash_write_block)( alt_flash_dev* flash, int block_offset, - int data_offset, const void* data, - int length); -typedef int (*alt_flash_erase_block)( alt_flash_dev* flash, int offset); -typedef int (*alt_flash_read)(alt_flash_dev* flash, int offset, - void* dest_addr, int length ); -typedef int (*alt_flash_lock)(alt_flash_dev* flash, alt_u32 sectors_to_lock); - -struct alt_flash_dev -{ - alt_llist llist; - const char* name; - alt_flash_open open; - alt_flash_close close; - alt_flash_write write; - alt_flash_read read; - alt_flash_get_flash_info get_info; - alt_flash_erase_block erase_block; - alt_flash_write_block write_block; - void* base_addr; - int length; - int number_of_regions; - flash_region region_info[ALT_MAX_NUMBER_OF_FLASH_REGIONS]; - alt_flash_lock lock; -}; - -#endif /* __ALT_FLASH_DEV_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_flash_types.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_flash_types.h deleted file mode 100644 index f7b3b0232c..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_flash_types.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef __ALT_FLASH_TYPES_H__ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -/****************************************************************************** -* * -* Alt_flash_types.h - Some generic types and defines used by the flash code * -* * -* Author PRR * -* * -******************************************************************************/ -#define __ALT_FLASH_TYPES_H__ - -#ifndef ALT_MAX_NUMBER_OF_FLASH_REGIONS -#define ALT_MAX_NUMBER_OF_FLASH_REGIONS 8 -#endif /* ALT_MAX_NUMBER_OF_FLASH_REGIONS */ - -/* - * Description of a single Erase region - */ -typedef struct flash_region -{ - int offset; - int region_size; - int number_of_blocks; - int block_size; -}flash_region; - -#endif /* __ALT_FLASH_TYPES_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_license_reminder_ucosii.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_license_reminder_ucosii.h deleted file mode 100644 index 4ac23c0d3e..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_license_reminder_ucosii.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef __ALT_LICENSE_REMINDER_UCOSII_H__ -#define __ALT_LICENSE_REMINDER_UCOSII_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#include - -#define ALT_LICENSE_REMINDER_UCOSII_STRING \ - "============== Software License Reminder ===============\n" \ - "\n" \ - "uC/OS-II is provided in source form for FREE evaluation,\n" \ - "for educational use, or for peaceful research. If you\n" \ - "plan on using uC/OS-II in a commercial product you need\n" \ - "to contact Micrium to properly license its use in your\n" \ - "product. Micrium provides ALL the source code on the\n" \ - "Altera distribution for your convenience and to help you\n" \ - "experience uC/OS-II. The fact that the source is provided\n" \ - "does NOT mean that you can use it without paying a\n" \ - "licensing fee. Please help us continue to provide the\n" \ - "Embedded community with the finest software available.\n" \ - "Your honesty is greatly appreciated.\n" \ - "\n" \ - "Please contact:\n" \ - "\n" \ - "M I C R I U M\n" \ - "949 Crestview Circle\n" \ - "Weston, FL 33327-1848\n" \ - "U.S.A.\n" \ - "\n" \ - "Phone : +1 954 217 2036\n" \ - "FAX : +1 954 217 2037\n" \ - "WEB : www.micrium.com\n" \ - "E-mail: Sales@Micrium.com\n" \ - "\n" \ - "========================================================\n" - -#define alt_license_reminder_ucosii() puts(ALT_LICENSE_REMINDER_UCOSII_STRING) - - -#endif /* __ALT_LICENSE_REMINDER_UCOSII_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_llist.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_llist.h deleted file mode 100644 index 446775ad81..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_llist.h +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef __ALT_LIST_H__ -#define __ALT_LIST_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#include "alt_types.h" - -/* - * alt_llist.h defines structures and functions for use in manipulating linked - * lists. A list is considered to be constructed from a chain of objects of - * type alt_llist, with one object being defined to be the head element. - * - * A list is considered to be empty if it only contains the head element. - */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * alt_llist is the structure used to represent an element within a linked - * list. - */ - -typedef struct alt_llist_s alt_llist; - -struct alt_llist_s { - alt_llist* next; /* Pointer to the next element in the list. */ - alt_llist* previous; /* Pointer to the previous element in the list. */ -}; - -/* - * ALT_LLIST_HEAD is a macro that can be used to create the head of a new - * linked list. This is named "head". The head element is initialised to - * represent an empty list. - */ - -#define ALT_LLIST_HEAD(head) alt_llist head = {&head, &head} - -/* - * ALT_LLIST_ENTRY is a macro used to define an uninitialised linked list - * entry. This is used to reserve space in structure initialisation for - * structures that inherit form alt_llist. - */ - -#define ALT_LLIST_ENTRY {0, 0} - -/* - * alt_llist_insert() insert adds the linked list entry "entry" as the - * first entry in the linked list "list". "list" is the list head element. - */ - -static ALT_INLINE void ALT_ALWAYS_INLINE alt_llist_insert(alt_llist* list, - alt_llist* entry) -{ - entry->previous = list; - entry->next = list->next; - - list->next->previous = entry; - list->next = entry; -} - -/* - * alt_llist_remove() is called to remove an element from a linked list. The - * input argument is the element to remove. - */ - -static ALT_INLINE void ALT_ALWAYS_INLINE alt_llist_remove(alt_llist* entry) -{ - entry->next->previous = entry->previous; - entry->previous->next = entry->next; - - /* - * Set the entry to point to itself, so that any further calls to - * alt_llist_remove() are harmless. - */ - - entry->previous = entry; - entry->next = entry; -} - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_LLIST_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_load.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_load.h deleted file mode 100644 index a97f5be16c..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_load.h +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2005 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -#include "alt_types.h" - -/* - * This macro is used to load code/data from its load address to its - * execution address for a given section. The section name is the input - * argument. Note that a leading '.' is assumed in the name. For example - * to load the section .onchip_ram, use: - * - * ALT_LOAD_SECTION_BY_NAME(onchip_ram); - * - * This requires that the apropriate linker symbols have been generated - * for the section in question. This will be the case if you are using the - * default linker script. - */ - -#define ALT_LOAD_SECTION_BY_NAME(name) \ - { \ - extern void _alt_partition_##name##_start; \ - extern void _alt_partition_##name##_end; \ - extern void _alt_partition_##name##_load_addr; \ - \ - alt_load_section(&_alt_partition_##name##_load_addr, \ - &_alt_partition_##name##_start, \ - &_alt_partition_##name##_end); \ - } - -/* - * Function used to load an individual section from flash to RAM. - * - * There is an implicit assumption here that the linker script will ensure - * that all sections are word aligned. - * - */ - -static void ALT_INLINE alt_load_section (alt_u32* from, - alt_u32* to, - alt_u32* end) -{ - if (to != from) - { - while( to != end ) - { - *to++ = *from++; - } - } -} diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_log_printf.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_log_printf.h deleted file mode 100644 index 36928f8f5d..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_log_printf.h +++ /dev/null @@ -1,353 +0,0 @@ -/* alt_log_printf.h - * - * ALT_LOG is designed to provide extra logging/debugging messages from HAL - * through a different port than stdout. It is enabled by the ALT_LOG_ENABLE - * define, which needs to supplied at compile time. When logging is turned off, - * code size is unaffected. Thus, this should be transparent to the user - * when it is not actively turned on, and should not affect projects in any way. - * - * There are macros sprinkled within different components, such as the jtag uart - * and timer, in the HAL code. They are always named ALT_LOG_, and can be - * safely ignored if ALT_LOG is turned off. - * - * To turn on ALT_LOG, ALT_LOG_ENABLE must be defined, and ALT_LOG_PORT_TYPE and - * ALT_LOG_PORT_BASE must be set in system.h. This is done through editing - * .ptf, by editing the alt_log_port_type & alt_log_port_base settings. - * See the documentation html file for examples. - * - * When it is turned on, it will output extra HAL messages to a port specified - * in system.h. This can be a UART or JTAG UART port. By default it will - * output boot messages, detailing every step of the boot process. - * - * Extra logging is designed to be enabled by flags, which are defined in - * alt_log_printf.c. The default value is that all flags are off, so only the - * boot up logging messages show up. ALT_LOG_FLAGS can be set to enable certain - * groupings of flags, and that grouping is done in this file. Each flag can - * also be overridden with a -D at compile time. - * - * This header file includes the necessary prototypes for using the alt_log - * functions. It also contains all the macros that are used to remove the code - * from alt log is turned off. Also, the macros in other HAL files are defined - * here at the bottom. These macros all call some C function that is in - * alt_log_printf.c. - * - * The logging has functions for printing in C (ALT_LOG_PRINTF) and in assembly - * (ALT_LOG_PUTS). This was needed because the assembly printing occurs before - * the device is initialized. The assembly function corrupts register R4-R7, - * which are not used in the normal boot process. For this reason, do not call - * the assembly function in C. - * - * author: gkwan - */ - - -#ifndef __ALT_LOG_PRINTF_H__ -#define __ALT_LOG_PRINTF_H__ - -#include - -/* Global switch to turn on logging functions */ -#ifdef ALT_LOG_ENABLE - - /* ALT_LOG_PORT_TYPE values as defined in system.h. They are defined as - * numbers here first becasue the C preprocessor does not handle string - * comparisons. */ - #define ALTERA_AVALON_JTAG_UART 1 - #define ALTERA_AVALON_UART 0 - - /* If this .h file is included by an assembly file, skip over include files - * that won't compile in assembly. */ - #ifndef ALT_ASM_SRC - #include - #include "sys/alt_alarm.h" - #include "sys/alt_dev.h" - #ifdef __ALTERA_AVALON_JTAG_UART - #include "altera_avalon_jtag_uart.h" - #endif - #endif /* ALT_ASM_SRC */ - - /* These are included for the port register offsets and masks, needed - * to write to the port. Only include if the port type is set correctly, - * otherwise error. If alt_log is turned on and the port to output to is - * incorrect or does not exist, then should exit. */ - #if ALT_LOG_PORT_TYPE == ALTERA_AVALON_JTAG_UART - #ifdef __ALTERA_AVALON_JTAG_UART - #include - #else - #error ALT_LOG: JTAG_UART port chosen, but no JTAG_UART in system. - #endif - #elif ALT_LOG_PORT_TYPE == ALTERA_AVALON_UART - #ifdef __ALTERA_AVALON_UART - #include - #else - #error ALT_LOG: UART Port chosen, but no UART in system. - #endif - #else - #error ALT_LOG: alt_log_port_type declaration invalid! - #endif - - /* ALT_LOG_ENABLE turns on the basic printing function */ - #define ALT_LOG_PRINTF(...) do {alt_log_printf_proc(__VA_ARGS__);} while (0) - - /* Assembly macro for printing in assembly, calls tx_log_str - * which is in alt_log_macro.S. - * If alt_log_boot_on_flag is 0, skips the printing */ - #define ALT_LOG_PUTS(str) movhi r4, %hiadj(alt_log_boot_on_flag) ; \ - addi r4, r4, %lo(alt_log_boot_on_flag) ; \ - ldwio r5, 0(r4) ; \ - beq r0, r5, 0f ; \ - movhi r4, %hiadj(str) ; \ - addi r4, r4, %lo(str) ; \ - call tx_log_str ; \ - 0: - - /* These defines are here to faciliate the use of one output function - * (alt_log_txchar) to print to both the JTAG UART or the UART. Depending - * on the port type, the status register, read mask, and output register - * are set to the appropriate value for the port. */ - #if ALT_LOG_PORT_TYPE == ALTERA_AVALON_JTAG_UART - #define ALT_LOG_PRINT_REG_RD IORD_ALTERA_AVALON_JTAG_UART_CONTROL - #define ALT_LOG_PRINT_MSK ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK - #define ALT_LOG_PRINT_TXDATA_WR IOWR_ALTERA_AVALON_JTAG_UART_DATA - #define ALT_LOG_PRINT_REG_OFFSET (ALTERA_AVALON_JTAG_UART_CONTROL_REG*0x4) - #define ALT_LOG_PRINT_TXDATA_REG_OFFSET (ALTERA_AVALON_JTAG_UART_DATA_REG*0x4) - #elif ALT_LOG_PORT_TYPE == ALTERA_AVALON_UART - #define ALT_LOG_PRINT_REG_RD IORD_ALTERA_AVALON_UART_STATUS - #define ALT_LOG_PRINT_MSK ALTERA_AVALON_UART_STATUS_TRDY_MSK - #define ALT_LOG_PRINT_TXDATA_WR IOWR_ALTERA_AVALON_UART_TXDATA - #define ALT_LOG_PRINT_REG_OFFSET (ALTERA_AVALON_UART_STATUS_REG*0x4) - #define ALT_LOG_PRINT_TXDATA_REG_OFFSET (ALTERA_AVALON_UART_TXDATA_REG*0x4) - #endif /* ALT_LOG_PORT */ - - /* Grouping of flags via ALT_LOG_FLAGS. Each specific flag can be set via - * -D at compile time, or else they'll be set to a default value according - * to ALT_LOG_FLAGS. ALT_LOG_FLAGS = 0 or not set is the default, where - * only the boot messages will be printed. As ALT_LOG_FLAGS increase, they - * increase in intrusiveness to the program, and will affect performance. - * - * Flag Level 1 - turns on system clock and JTAG UART startup status - * 2 - turns on write echo and JTAG_UART alarm (periodic report) - * 3 - turns on JTAG UART ISR logging - will slow performance - * significantly. - * -1 - All logging output is off, but if ALT_LOG_ENABLE is - * defined all logging function is built and code size - * remains constant - * - * Flag settings - 1 = on, 0 = off. */ - - /* This flag turns on "boot" messages for printing. This includes messages - * during crt0.S, then alt_main, and finally alt_exit. */ - #ifndef ALT_LOG_BOOT_ON_FLAG_SETTING - #if ALT_LOG_FLAGS == 1 - #define ALT_LOG_BOOT_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == 2 - #define ALT_LOG_BOOT_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == 3 - #define ALT_LOG_BOOT_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == -1 /* silent mode */ - #define ALT_LOG_BOOT_ON_FLAG_SETTING 0x0 - #else /* default setting */ - #define ALT_LOG_BOOT_ON_FLAG_SETTING 0x1 - #endif - #endif /* ALT_LOG_BOOT_ON_FLAG_SETTING */ - - #ifndef ALT_LOG_SYS_CLK_ON_FLAG_SETTING - #if ALT_LOG_FLAGS == 1 - #define ALT_LOG_SYS_CLK_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == 2 - #define ALT_LOG_SYS_CLK_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == 3 - #define ALT_LOG_SYS_CLK_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == -1 /* silent mode */ - #define ALT_LOG_SYS_CLK_ON_FLAG_SETTING 0x0 - #else /* default setting */ - #define ALT_LOG_SYS_CLK_ON_FLAG_SETTING 0x0 - #endif - #endif /* ALT_LOG_SYS_CLK_ON_FLAG_SETTING */ - - #ifndef ALT_LOG_WRITE_ON_FLAG_SETTING - #if ALT_LOG_FLAGS == 1 - #define ALT_LOG_WRITE_ON_FLAG_SETTING 0x0 - #elif ALT_LOG_FLAGS == 2 - #define ALT_LOG_WRITE_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == 3 - #define ALT_LOG_WRITE_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == -1 /* silent mode */ - #define ALT_LOG_WRITE_ON_FLAG_SETTING 0x0 - #else /* default setting */ - #define ALT_LOG_WRITE_ON_FLAG_SETTING 0x0 - #endif - #endif /* ALT_LOG_WRITE_ON_FLAG_SETTING */ - - #ifndef ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING - #ifndef __ALTERA_AVALON_JTAG_UART - #define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x0 - #elif ALT_LOG_FLAGS == 1 - #define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x0 - #elif ALT_LOG_FLAGS == 2 - #define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == 3 - #define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == -1 /* silent mode */ - #define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x0 - #else /* default setting */ - #define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x0 - #endif - #endif /* ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING */ - - #ifndef ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING - #ifndef __ALTERA_AVALON_JTAG_UART - #define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x0 - #elif ALT_LOG_FLAGS == 1 - #define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == 2 - #define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == 3 - #define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == -1 /* silent mode */ - #define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x0 - #else /* default setting */ - #define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x0 - #endif - #endif /* ALT_LOG_JTAG_UART_STARTUP_INFO_FLAG_SETTING */ - - #ifndef ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING - #ifndef __ALTERA_AVALON_JTAG_UART - #define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x0 - #elif ALT_LOG_FLAGS == 1 - #define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x0 - #elif ALT_LOG_FLAGS == 2 - #define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x0 - #elif ALT_LOG_FLAGS == 3 - #define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x1 - #elif ALT_LOG_FLAGS == -1 /* silent mode */ - #define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x0 - #else /* default setting */ - #define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x0 - #endif - #endif /* ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING */ - -#ifndef ALT_ASM_SRC - /* Function Prototypes */ - void alt_log_txchar(int c,char *uartBase); - void alt_log_private_printf(const char *fmt,int base,va_list args); - void alt_log_repchar(char c,int r,int base); - int alt_log_printf_proc(const char *fmt, ... ); - void alt_log_system_clock(); - #ifdef __ALTERA_AVALON_JTAG_UART - alt_u32 altera_avalon_jtag_uart_report_log(void * context); - void alt_log_jtag_uart_startup_info(altera_avalon_jtag_uart_state* dev, int base); - void alt_log_jtag_uart_print_control_reg(altera_avalon_jtag_uart_state* dev, \ - int base, const char* header); - void alt_log_jtag_uart_isr_proc(int base, altera_avalon_jtag_uart_state* dev); - #endif - void alt_log_write(const void *ptr, size_t len); - - /* extern all global variables */ - /* CASE:368514 - The boot message flag is linked into the sdata section - * because if it is zero, it would otherwise be placed in the bss section. - * alt_log examines this variable before the BSS is cleared in the boot-up - * process. - */ - extern volatile alt_u32 alt_log_boot_on_flag __attribute__ ((section (".sdata"))); - extern volatile alt_u8 alt_log_write_on_flag; - extern volatile alt_u8 alt_log_sys_clk_on_flag; - extern volatile alt_u8 alt_log_jtag_uart_alarm_on_flag; - extern volatile alt_u8 alt_log_jtag_uart_isr_on_flag; - extern volatile alt_u8 alt_log_jtag_uart_startup_info_on_flag; - extern volatile int alt_log_sys_clk_count; - extern volatile int alt_system_clock_in_sec; - extern alt_alarm alt_log_jtag_uart_alarm_1; -#endif /* ALT_ASM_SRC */ - - - /* Below are the MACRO defines used in various HAL files. They check - * if their specific flag is turned on; if it is, then it executes its - * code. - * - * To keep this file reasonable, most of these macros calls functions, - * which are defined in alt_log_printf.c. Look there for implementation - * details. */ - - /* Boot Messages Logging */ - #define ALT_LOG_PRINT_BOOT(...) \ - do { if (alt_log_boot_on_flag==1) {ALT_LOG_PRINTF(__VA_ARGS__);} \ - } while (0) - - /* JTAG UART Logging */ - /* number of ticks before alarm runs logging function */ - #ifndef ALT_LOG_JTAG_UART_TICKS_DIVISOR - #define ALT_LOG_JTAG_UART_TICKS_DIVISOR 10 - #endif - #ifndef ALT_LOG_JTAG_UART_TICKS - #define ALT_LOG_JTAG_UART_TICKS \ - (alt_ticks_per_second()/ALT_LOG_JTAG_UART_TICKS_DIVISOR) - #endif - - /* if there's a JTAG UART defined, then enable these macros */ - #ifdef __ALTERA_AVALON_JTAG_UART - - /* Macro in altera_avalon_jtag_uart.c, to register the alarm function. - * Also, the startup register info is also printed here, as this is - * called within the device driver initialization. */ - #define ALT_LOG_JTAG_UART_ALARM_REGISTER(dev, base) \ - do { if (alt_log_jtag_uart_alarm_on_flag==1) { \ - alt_alarm_start(&alt_log_jtag_uart_alarm_1, \ - ALT_LOG_JTAG_UART_TICKS, &altera_avalon_jtag_uart_report_log,\ - dev);} \ - if (alt_log_jtag_uart_startup_info_on_flag==1) {\ - alt_log_jtag_uart_startup_info(dev, base);} \ - } while (0) - - /* JTAG UART IRQ Logging (when buffer is empty) - * Inserted in the ISR in altera_avalon_jtag_uart.c */ - #define ALT_LOG_JTAG_UART_ISR_FUNCTION(base, dev) \ - do { alt_log_jtag_uart_isr_proc(base, dev); } while (0) - /* else, define macros to nothing. Or else the jtag_uart specific types - * will throw compiler errors */ - #else - #define ALT_LOG_JTAG_UART_ALARM_REGISTER(dev, base) - #define ALT_LOG_JTAG_UART_ISR_FUNCTION(base, dev) - #endif - - /* System clock logging - * How often (in seconds) the system clock logging prints. - * The default value is every 1 second */ - #ifndef ALT_LOG_SYS_CLK_INTERVAL_MULTIPLIER - #define ALT_LOG_SYS_CLK_INTERVAL_MULTIPLIER 1 - #endif - #ifndef ALT_LOG_SYS_CLK_INTERVAL - #define ALT_LOG_SYS_CLK_INTERVAL \ - (alt_ticks_per_second()*ALT_LOG_SYS_CLK_INTERVAL_MULTIPLIER) - #endif - - /* System clock logging - prints a message every interval (set above) - * to show that the system clock is alive. - * This macro is used in altera_avalon_timer_sc.c */ - #define ALT_LOG_SYS_CLK_HEARTBEAT() \ - do { alt_log_system_clock(); } while (0) - - /* alt_write_logging - echos a message every time write() is called, - * displays the first ALT_LOG_WRITE_ECHO_LEN characters. - * This macro is used in alt_write.c */ - #ifndef ALT_LOG_WRITE_ECHO_LEN - #define ALT_LOG_WRITE_ECHO_LEN 15 - #endif - - #define ALT_LOG_WRITE_FUNCTION(ptr,len) \ - do { alt_log_write(ptr,len); } while (0) - -#else /* ALT_LOG_ENABLE not defined */ - - /* logging is off, set all relevant macros to null */ - #define ALT_LOG_PRINT_BOOT(...) - #define ALT_LOG_PRINTF(...) - #define ALT_LOG_JTAG_UART_ISR_FUNCTION(base, dev) - #define ALT_LOG_JTAG_UART_ALARM_REGISTER(dev, base) - #define ALT_LOG_SYS_CLK_HEARTBEAT() - #define ALT_LOG_PUTS(str) - #define ALT_LOG_WRITE_FUNCTION(ptr,len) - -#endif /* ALT_LOG_ENABLE */ - -#endif /* __ALT_LOG_PRINTF_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_set_args.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_set_args.h deleted file mode 100644 index ecd04e13c6..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_set_args.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef __ALT_SET_ARGS_H__ -#define __ALT_SET_ARGS_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * The function alt_set_args() is provided in order to define the input - * arguments to main(). If this function is not called before main() then the - * argument list passed to main() will be empty. - * - * It is expected that this function will only be used by the ihost/iclient - * utility. - */ - -static inline void alt_set_args (int argc, char** argv, char** envp) -{ - extern int alt_argc; - extern char** alt_argv; - extern char** alt_envp; - - alt_argc = argc; - alt_argv = argv; - alt_envp = envp; -} - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_SET_ARGS_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_stdio.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_stdio.h deleted file mode 100644 index b9007a5d4f..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_stdio.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef __ALT_STDIO_H__ -#define __ALT_STDIO_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2015 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -/* - * Definitions for ALT stdio routines. - */ - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -int alt_getchar(); -int alt_putchar(int c); -int alt_putstr(const char* str); -void alt_printf(const char *fmt, ...); -#ifdef ALT_SEMIHOSTING -int alt_putcharbuf(int c); -int alt_putstrbuf(const char* str); -int alt_putbufflush(); -#endif -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_STDIO_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_sys_init.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_sys_init.h deleted file mode 100644 index 29926e4dad..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_sys_init.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef __ALT_SYS_INIT_H__ -#define __ALT_SYS_INIT_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * The function alt_sys_init() is defined within the auto-generated file: - * alt_sys_init.c. This function calls the initilisation macros for all - * devices, file systems, and software components within the system. - * - * The list of initilisation macros to use is constructed using the PTF and - * STF files associated with the system. - */ - -extern void alt_sys_init (void); - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_SYS_INIT_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_sys_wrappers.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_sys_wrappers.h deleted file mode 100644 index 4939dff7f0..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_sys_wrappers.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __ALT_SYS_WRAPPERS_H__ -#define __ALT_SYS_WRAPPERS_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/* - * This file provides the prototypes for the HAL 'UNIX style functions. The - * names of these functions are defined in alt_syscall.h. THese are defined to - * be the standard names when running the standalone HAL, e.g. open(), close() - * etc., but the names may be redefined as a part of an operating system port - * in order to avoid name clashes. - */ - -#include "os/alt_syscall.h" - -#include -#include -#include -#include -#include -#include - -extern int ALT_CLOSE (int __fd); -extern int ALT_EXECVE (const char *__path, - char * const __argv[], - char * const __envp[]); -extern void ALT_EXIT (int __status); -extern int ALT_FSTAT (int file, struct stat *st); -extern int ALT_FCNTL (int file, int cmd, ...); -extern pid_t ALT_FORK (void); -extern pid_t ALT_GETPID (void); - -#if defined (__GNUC__) && __GNUC__ >= 4 -extern int ALT_GETTIMEOFDAY (struct timeval *ptimeval, - void *ptimezone); -#else -extern int ALT_GETTIMEOFDAY (struct timeval *ptimeval, - struct timezone *ptimezone); -#endif - -extern int ALT_IOCTL (int file, int req, void* arg); -extern int ALT_ISATTY (int file); -extern int ALT_KILL (int pid, int sig); -extern int ALT_LINK (const char *existing, const char *new); -extern off_t ALT_LSEEK (int file, off_t ptr, int dir); -extern int ALT_OPEN (const char* file, int flags, ...); -extern int ALT_READ (int file, void *ptr, size_t len); -extern int ALT_RENAME (char *existing, char *new); -extern void* ALT_SBRK (ptrdiff_t incr); -extern int ALT_SETTIMEOFDAY (const struct timeval *t, - const struct timezone *tz); -extern int ALT_STAT (const char *file, struct stat *st); -extern clock_t ALT_TIMES (struct tms *buf); -extern int ALT_UNLINK (const char *name); - -#if defined (__GNUC__) && __GNUC__ >= 4 -int ALT_USLEEP (useconds_t us); -#else -unsigned int ALT_USLEEP (unsigned int us); -#endif - -extern int ALT_WAIT (int *status); -extern int ALT_WRITE (int file, const void *ptr, size_t len); - - -extern char** ALT_ENVIRON; - -/* - * - */ - -#endif /* __ALT_SYS_WRAPPERS_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_timestamp.h b/ext/hal/altera/altera_hal/HAL/inc/sys/alt_timestamp.h deleted file mode 100644 index 29c5dba038..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/alt_timestamp.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef __ALT_TIMESTAMP_H__ -#define __ALT_TIMESTAMP_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#include "alt_types.h" -#include "altera_avalon_timer.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -extern int alt_timestamp_start (void); - -extern alt_timestamp_type alt_timestamp (void); - -extern alt_u32 alt_timestamp_freq (void); - -#ifdef __cplusplus -} -#endif - -#endif /* __ALT_TIMESTAMP_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/ioctl.h b/ext/hal/altera/altera_hal/HAL/inc/sys/ioctl.h deleted file mode 100644 index 9ace720bf1..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/ioctl.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef __IOCTL_H__ -#define __IOCTL_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * The ioctl() system call be used to initiate a variety of control operations - * on a file descriptor. For the most part this simply translates to a call to - * the ioctl() function of the associated device driver (TIOCEXCL and - * TIOCNXCL are notable exceptions - see ioctl.c for details). - * - * The interpretation of the ioctl requests are therefore device specific. - * - * This function is equivalent to the standard Posix ioctl() call. - */ - -extern int ioctl (int fd, int req, void* arg); - -/* - * list of ioctl calls handled by the system ioctl implementation. - */ - -#define TIOCEXCL 0x740d /* exclusive use of the device */ -#define TIOCNXCL 0x740e /* allow multiple use of the device */ - -/* - * ioctl calls which can be handled by device drivers. - */ - -#define TIOCOUTQ 0x7472 /* get output queue size */ -#define TIOCMGET 0x741d /* get termios flags */ -#define TIOCMSET 0x741a /* set termios flags */ - -/* - * ioctl calls specific to JTAG UART. - */ - -#define TIOCSTIMEOUT 0x6a01 /* Set Timeout before assuming no host present */ -#define TIOCGCONNECTED 0x6a02 /* Get indication of whether host is connected */ - -/* - * - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __IOCTL_H__ */ diff --git a/ext/hal/altera/altera_hal/HAL/inc/sys/termios.h b/ext/hal/altera/altera_hal/HAL/inc/sys/termios.h deleted file mode 100644 index 7d0b4c32a9..0000000000 --- a/ext/hal/altera/altera_hal/HAL/inc/sys/termios.h +++ /dev/null @@ -1,178 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/****************************************************************************** -* * -* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. * -* * -******************************************************************************/ - -/* - * This is the termios.h file provided with newlib. The only modification has - * been to the baud rate macro definitions, and an increase in the size of the - * termios structure to accomodate this. - */ - - -#ifndef _SYS_TERMIOS_H -# define _SYS_TERMIOS_H - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -# define _XCGETA (('x'<<8)|1) -# define _XCSETA (('x'<<8)|2) -# define _XCSETAW (('x'<<8)|3) -# define _XCSETAF (('x'<<8)|4) -# define _TCSBRK (('T'<<8)|5) -# define _TCFLSH (('T'<<8)|7) -# define _TCXONC (('T'<<8)|6) - -# define TCOOFF 0 -# define TCOON 1 -# define TCIOFF 2 -# define TCION 3 - -# define TCIFLUSH 0 -# define TCOFLUSH 1 -# define TCIOFLUSH 2 - -# define NCCS 13 - -# define TCSAFLUSH _XCSETAF -# define TCSANOW _XCSETA -# define TCSADRAIN _XCSETAW -# define TCSADFLUSH _XCSETAF - -# define IGNBRK 000001 -# define BRKINT 000002 -# define IGNPAR 000004 -# define INPCK 000020 -# define ISTRIP 000040 -# define INLCR 000100 -# define IGNCR 000200 -# define ICRNL 000400 -# define IXON 002000 -# define IXOFF 010000 - -# define OPOST 000001 -# define OCRNL 000004 -# define ONLCR 000010 -# define ONOCR 000020 -# define TAB3 014000 - -# define CLOCAL 004000 -# define CREAD 000200 -# define CSIZE 000060 -# define CS5 0 -# define CS6 020 -# define CS7 040 -# define CS8 060 -# define CSTOPB 000100 -# define HUPCL 002000 -# define PARENB 000400 -# define PAODD 001000 - -#define CCTS_OFLOW 010000 -#define CRTS_IFLOW 020000 -#define CRTSCTS (CCTS_OFLOW | CRTS_IFLOW) - -# define ECHO 0000010 -# define ECHOE 0000020 -# define ECHOK 0000040 -# define ECHONL 0000100 -# define ICANON 0000002 -# define IEXTEN 0000400 /* anybody know *what* this does?! */ -# define ISIG 0000001 -# define NOFLSH 0000200 -# define TOSTOP 0001000 - -# define VEOF 4 /* also VMIN -- thanks, AT&T */ -# define VEOL 5 /* also VTIME -- thanks again */ -# define VERASE 2 -# define VINTR 0 -# define VKILL 3 -# define VMIN 4 /* also VEOF */ -# define VQUIT 1 -# define VSUSP 10 -# define VTIME 5 /* also VEOL */ -# define VSTART 11 -# define VSTOP 12 - -# define B0 0 -# define B50 50 -# define B75 75 -# define B110 110 -# define B134 134 -# define B150 150 -# define B200 200 -# define B300 300 -# define B600 600 -# define B1200 1200 -# define B1800 1800 -# define B2400 2400 -# define B4800 4800 -# define B9600 9600 -# define B19200 19200 -# define B38400 38400 -# define B57600 57600 -# define B115200 115200 - -typedef unsigned char cc_t; -typedef unsigned short tcflag_t; -typedef unsigned long speed_t; - -struct termios { - tcflag_t c_iflag; - tcflag_t c_oflag; - tcflag_t c_cflag; - tcflag_t c_lflag; - char c_line; - cc_t c_cc[NCCS]; - speed_t c_ispeed; - speed_t c_ospeed; -}; - -# ifndef _NO_MACROS - -# define cfgetospeed(tp) ((tp)->c_ospeed) -# define cfgetispeed(tp) ((tp)->c_ispeed) -# define cfsetospeed(tp,s) (((tp)->c_ospeed = (s)), 0) -# define cfsetispeed(tp,s) (((tp)->c_ispeed = (s)), 0) -# define tcdrain(fd) _ioctl (fd, _TCSBRK, 1) -# endif /* _NO_MACROS */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_TERMIOS_H */ diff --git a/ext/hal/altera/altera_hal/HAL/src/CMakeLists.txt b/ext/hal/altera/altera_hal/HAL/src/CMakeLists.txt deleted file mode 100644 index b3dd30da68..0000000000 --- a/ext/hal/altera/altera_hal/HAL/src/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -zephyr_sources(altera_common.c) diff --git a/ext/hal/altera/altera_hal/HAL/src/altera_common.c b/ext/hal/altera/altera_hal/HAL/src/altera_common.c deleted file mode 100644 index 58e335ca40..0000000000 --- a/ext/hal/altera/altera_hal/HAL/src/altera_common.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "sys/alt_irq.h" -#include "altera_common.h" - -#define ALTERA_MAX_IRQ 32 - -static alt_isr_func alt_hal_isr[ALTERA_MAX_IRQ]; - -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT -int alt_ic_isr_register(alt_u32 ic_id, alt_u32 irq, - alt_isr_func isr, void *isr_context, void *flags) - -{ - if (irq <= ALTERA_MAX_IRQ) - { - alt_hal_isr[irq] = isr; - return 0; - } - else - { - return -EINVAL; - } - -} -#else -int alt_irq_register(alt_u32 irq, void* context, alt_isr_func isr) -{ - if (irq <= ALTERA_MAX_IRQ) - { - alt_hal_isr[irq] = isr; - return 0; - } - else - { - return -EINVAL; - } -} -#endif - -void alt_handle_irq(void* base, alt_u32 id) -{ - /* Null pointer check for handler function */ - if (!alt_hal_isr[id]) - return; - -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT - alt_hal_isr[id]((void*)base); -#else - alt_hal_isr[id]((void*)base, id); -#endif -} - - -/* Add Altera HAL extern function definations here */ - -/* - * alt_tick() should only be called by the system clock driver. This is used - * to notify the system that the system timer period has expired. - */ - -void alt_tick (void) -{ -} - -#include "priv/alt_dev_llist.h" -int alt_dev_llist_insert (alt_dev_llist* dev, alt_llist* list) -{ - return 0; -} - -#include "priv/alt_busy_sleep.h" -#include -unsigned int alt_busy_sleep (unsigned int us) -{ - k_busy_wait(us); - return 0; -} - -void alt_printf(const char *fmt, ...) -{ -} diff --git a/ext/hal/altera/drivers/altera_avalon_i2c/HAL/inc/altera_avalon_i2c.h b/ext/hal/altera/drivers/altera_avalon_i2c/HAL/inc/altera_avalon_i2c.h deleted file mode 100644 index 7493487820..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_i2c/HAL/inc/altera_avalon_i2c.h +++ /dev/null @@ -1,1434 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2016 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/*! \file - * Altera Avalon I2C Controller API - */ - -#ifndef __ALT_AVALON_I2C_H__ -#define __ALT_AVALON_I2C_H__ - -#include -#include - -#include "sys/alt_dev.h" -#include "alt_types.h" -#include "altera_avalon_i2c_regs.h" -#include "os/alt_sem.h" -#include "os/alt_flag.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * The function alt_find_dev() is used to search the device list "list" to - * locate a device named "name". If a match is found, then a pointer to the - * device is returned, otherwise NULL is returned. - */ -extern alt_dev* alt_find_dev (const char* name, alt_llist* list); - -/* Callback routine type definition */ -typedef void (*alt_avalon_i2c_callback)(void *context); - -/******************************************************************************/ -/*! \addtogroup ALT_AVALON_I2C I2C Controller API - * - * This document defines the API for configuring and managing the Avalon I2C controller. - * - * The I2C controller provides support for a communication link between integrated - * circuits on a board. It is a simple two-wire bus which consists of a serial - * data line (SDA) and a serial clock (SCL) for use in applications such as - * temperature sensors and voltage level translators to EEPROMs, A/D and D/A - * converters, CODECs, and many types of microprocessors. - * - * The Avalon (FPGA) I2C controller IP enables system - * software to communicate serially with I2C buses. Each I2C controller can - * operate in master mode only, and supports standard mode of up to 100 - * kilobits per second (Kbps) or fast mode of up to 400 Kbps. - * - * - * Features of the I2C Controller: - * * Supports both 100 KBps and 400 KBps modes - * * Supports I2C master mode - * * Support both 7-bit and 10-bit addressing modes - * * Mixed read and write combined-format transactions - * * Bulk transmit and receive - * * Interrupt support - * * CMD and RX Fifos - * - * For complete details on the configuration and operation of the I2C controller, - * consult the following references: - * * Altera Avalon I2C Core Functional Description - * - * @{ - */ - - - -/* Status Codes */ -typedef alt_u32 ALT_AVALON_I2C_STATUS_CODE; -#define ALT_AVALON_I2C_TRUE (1) -#define ALT_AVALON_I2C_FALSE (0) -#define ALT_AVALON_I2C_SUCCESS (0) -#define ALT_AVALON_I2C_ERROR (-1) -#define ALT_AVALON_I2C_TIMEOUT (-2) -#define ALT_AVALON_I2C_BAD_ARG (-3) -#define ALT_AVALON_I2C_RANGE (-4) -#define ALT_AVALON_I2C_NACK_ERR (-5) -#define ALT_AVALON_I2C_ARB_LOST_ERR (-6) -#define ALT_AVALON_I2C_BUSY (-7) - -/******************************************************************************/ -/*! \addtogroup INSTANCEFUNCTIONS I2C Instance Init Functions - * - * These functions are used by the system structure when initializing - * the I2C instance. These functions are not typically called by a - * user of the I2C IP except for the alt_avalon_i2c_open() - * function which is required to obtain a pointer to the desired I2C - * instance. - * - * @{ - */ - - /* constant used in the alt_avalon_i2c_send_address routine */ - #define TARGET_ADDR_MASK_10BIT 0x7800 - - /*! - * This type enumerates the two addressing modes formats supported by the I2C - * controller. - * - * The I2C controller does not support mixed address format - that is, a 7-bit - * address transaction followed by a 10-bit address transaction or vice versa - - * combined format transactions. - */ -typedef enum ALT_AVALON_I2C_ADDR_MODE_e -{ - ALT_AVALON_I2C_ADDR_MODE_7_BIT = 0, - /*!< 7-Bit Address Format */ - ALT_AVALON_I2C_ADDR_MODE_10_BIT = 1 - /*!< 10-Bit Address Format */ -} ALT_AVALON_I2C_ADDR_MODE_t; - - /*! - * A pointer or handle to the I2C controller device instance. The ALT_AVALON_I2C_DEV_t is - * initialized by a call to alt_avalon_i2c_init() and subsequently used by the other I2C - * controller API functions as a reference to a specific device. - * - */ -typedef struct ALT_AVALON_I2C_DEV_s -{ - - alt_llist llist; - /*!< Device linked-list entry */ - const char *name; - /*!< Name of i2c in Qsys system */ - alt_u32 *i2c_base; - /*!< Base address of regs */ - alt_u32 irq_controller_ID; - /*!< device IRQ controller ID */ - alt_u32 irq_ID; - /*!< device IRQ ID */ - alt_avalon_i2c_callback callback; - /*!< Callback routine pointer */ - void *callback_context; - /*!< Callback context pointer */ - alt_u32 control; - /*!< user define control setting during interrupt registering*/ - alt_u32 master_target_address; - /*!< master target address */ - alt_u32 cmd_fifo_size; - /*!< cmd fifo */ - alt_u32 rx_fifo_size; - /*!< rx fifo */ - alt_u32 ip_freq_in_hz; - /*!< freq of clock to ip */ - ALT_AVALON_I2C_ADDR_MODE_t address_mode; - /*!< address mode 7 or 10 bit */ - ALT_SEM (regs_lock); - /*!< Semaphore used to control access registers - in multi-threaded mode */ -} ALT_AVALON_I2C_DEV_t; - -/*! - * The allocation of the ALT_AVALON_I2C_DEV_t structure memory - * and initial settings. - * - */ -#define ALTERA_AVALON_I2C_INSTANCE(name, dev) \ -static ALT_AVALON_I2C_DEV_t dev = \ -{ \ - ALT_LLIST_ENTRY, \ - name##_NAME, \ - ((alt_u32 *)(name##_BASE)), \ - ((alt_u32)(name##_IRQ_INTERRUPT_CONTROLLER_ID)), \ - ((alt_u32)(name##_IRQ)), \ - ((void *) 0x0), \ - ((void *) 0x0), \ - ((alt_u32)(0)), \ - ((alt_u32)(0)), \ - ((alt_u32)(name##_FIFO_DEPTH)), \ - ((alt_u32)(name##_FIFO_DEPTH)), \ - ((alt_u32)(name##_FREQ)), \ - ((ALT_AVALON_I2C_ADDR_MODE_t)(0)), \ -}; - -/*! - * Initialize the specified I2C controller instance. This routine is called from the - * ALTERA_AVALON_I2C_INIT macro and is called automatically by alt_sys_init.c - * - * This routine disables interrupts, - * registers a specific instance of the device with the HAL, - * and installs an interrupt handler for the device. - * - * \param i2c_dev - * The Avalon FPGA I2C controller instance to initialize. - * - * - */ -void alt_avalon_i2c_init(ALT_AVALON_I2C_DEV_t *i2c_dev); - -/* - * The macro ALTERA_AVALON_I2C_INIT is called by the auto-generated function - * alt_sys_init() to initialize a given device instance. - */ -#define ALTERA_AVALON_I2C_INIT(name, dev) alt_avalon_i2c_init(&dev); - -/*! - * Retrieve a pointer to the i2c block instance - * Search the list of registered i2c instances for one with the supplied name. - * - * \retval NULL The return value will be NULL on failure - * \retval non-NULL Success, ptr to i2c device instance returned. - * - * \param *name Character pointer to name of i2c peripheral as registered - * with the HAL. For example, an i2c controller named "i2c_0" - * in Qsys would be opened by asking for "/dev/i2c_0". - * - */ -ALT_AVALON_I2C_DEV_t* alt_avalon_i2c_open(const char* name); - -/*! @} */ - -/******************************************************************************/ -/*! \addtogroup SPEEDANDTIMINGFUNCTIONS Speed and Timing Configuration Functions - * - * These functions are used to set the Speed and Timing parameters. - * The ALT_AVALON_I2C_MASTER_CONFIG_t structure - * is used to set or get the speed, address mode, and scl/sda timing counts of the instance. - * The timing parameters can be set or retrieved in terms of Hz by using the - * alt_avalon_i2c_master_config_speed_get and alt_avalon_i2c_master_config_speed_set functions. - * - * @{ - */ - -/*! - * This type enumerates the I2C controller operational speed modes. - * - * The I2C controller can operate in standard mode (with data rates 0 to 100 Kbps) - * or fast mode (with data rates less than or equal to 400 Kbps). Additionally, - * fast mode devices are downward compatible. For instance, fast mode devices can - * communicate with standard mode devices in 0 to 100 Kbps I2C bus - * system. However, standard mode devices are not upward compatible and should not - * be incorporated in a fast-mode I2C bus system as they cannot follow the higher - * transfer rate and therefore unpredictable states would occur. - * - */ -typedef enum ALT_AVALON_I2C_SPEED_e -{ - ALT_AVALON_I2C_SPEED_STANDARD = 0, - /*!< Standard mode (0 to 100 Kbps) */ - ALT_AVALON_I2C_SPEED_FAST = 1 - /*!< Fast mode (<= 400 Kbps) */ -} ALT_AVALON_I2C_SPEED_t; - -/*! - * This type enumerates the I2C controller max min speeds in hz. - * - * The I2C controller can operate in standard mode (with data rates 0 to 100 Kbps) - * or fast mode (with data rates less than or equal to 400 Kbps). - * - */ -typedef enum ALT_AVALON_I2C_MAX_MIN_HZ_e -{ - ALT_AVALON_I2C_FS_MAX_HZ = 400000, - /*!< Max speed is 400Khz */ - ALT_AVALON_I2C_FS_MIN_HZ = 100000, - /*!< Min speed is 100Khz */ - ALT_AVALON_I2C_SS_MAX_HZ = 100000, - /*!< Max speed is 100Khz */ - ALT_AVALON_I2C_SS_MIN_HZ = 1 - /*!< Min speed is 1hz */ -} ALT_AVALON_I2C_MAX_MIN_HZ_t; - - -#define ALT_AVALON_I2C_DIFF_LCNT_HCNT 60 - -/*! - * This type defines a structure for configuration of the SCL high and low counts - * to ensure proper I/O timing with the device interface. - * - * See: Clock Frequency Configuration section of Chapter 20. I2C - * Controller in the Cyclone V Device Handbook Volume 3: Hard - * Processor System Technical Reference Manual for a complete discussion - * of calculation of the proper SCL clock high and low times. - */ -typedef struct ALT_AVALON_I2C_MASTER_CONFIG_s -{ - ALT_AVALON_I2C_ADDR_MODE_t addr_mode; - /*!< The address mode (7 or 10 bit) when - * acting as a master. - */ - ALT_AVALON_I2C_SPEED_t speed_mode; - /*!< The speed mode of the I2C operation. - */ - alt_u16 scl_hcnt; - /*!< The SCL clock high-period count. - */ - alt_u16 scl_lcnt; - /*!< The SCL clock low-period count. - */ - alt_u16 sda_cnt; - /*!< The SDA clock hold count. - */ -} ALT_AVALON_I2C_MASTER_CONFIG_t; - -/*! - * Populates the master mode configuration structure (type ALT_AVALON_I2C_ADDR_MODE_t) from registers. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param cfg - * [out] Pointer to a ALT_AVALON_I2C_MASTER_CONFIG_t structure for holding - * the returned I2C master mode configuration parameters. - * - * - */ -void alt_avalon_i2c_master_config_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - ALT_AVALON_I2C_MASTER_CONFIG_t* cfg); - -/*! - * Sets the registers based on the master mode configuration structure (type ALT_AVALON_I2C_ADDR_MODE_t). - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param cfg - * Pointer to a ALT_AVALON_I2C_MASTER_CONFIG_t structure holding the desired - * I2C master mode operational parameters. - * - * - */ -void alt_avalon_i2c_master_config_set(ALT_AVALON_I2C_DEV_t *i2c_dev, - const ALT_AVALON_I2C_MASTER_CONFIG_t* cfg); - -/*! - * This utility function returns the speed in hz based on the contents of the passed in configuration structure. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param cfg - * A pointer to a master configuration structure. - * - * \param speed_in_hz - * [out] Speed (Hz) the I2C bus is currently configured at based on - * the cfg structure (not necessarily on the hardware settings). - * To get the hardware speed first populate the cfg structure - * with the alt_avalon_i2c_master_config_get() function. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_config_speed_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - const ALT_AVALON_I2C_MASTER_CONFIG_t* cfg, - alt_u32 * speed_in_hz); - -/*! - * This is a utility function that computes parameters for the I2C master - * configuration that best matches the speed requested. Only the cfg - * structure passed in is modified. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param cfg - * A pointer to a master configuration structure. - * - * \param speed_in_hz - * Desired Speed (Hz) of the I2C bus. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_config_speed_set(ALT_AVALON_I2C_DEV_t *i2c_dev, - ALT_AVALON_I2C_MASTER_CONFIG_t * cfg, - alt_u32 speed_in_hz); - -/*! @} */ - -/******************************************************************************/ -/*! \addtogroup HELPERFUNCTIONS Helper Functions - * - * These helper functions are used by the I2C transaction functions. - * - * @{ - */ - - /* Descriptive Constants */ -#define ALT_AVALON_I2C_READ (1) -#define ALT_AVALON_I2C_WRITE (0) -#define ALT_AVALON_I2C_NO_RESTART (0) -#define ALT_AVALON_I2C_NO_STOP (0) -#define ALT_AVALON_I2C_RESTART (1) -#define ALT_AVALON_I2C_STOP (1) -#define ALT_AVALON_I2C_USE_INTERRUPTS (1) -#define ALT_AVALON_I2C_NO_INTERRUPTS (0) - -/*! - * Disables the I2C controller. - * - * When the I2C controller is disabled, the TX_READY_EN interrupt is cleared. - * However, the IP is not designed to be able to disable the IP in the middle - * of a transaction so this should be avoided. This disable function must - * be done at the end of every START -> STOP sequence. - * Before doing this function, wait for the IP to not be busy using the - * alt_avalon_i2c_is_busy function. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * - */ - void alt_avalon_i2c_disable(ALT_AVALON_I2C_DEV_t *i2c_dev); - -/*! - * Enables the I2C controller. This function is done at the beginning of - * every START->STOP sequence. - * This function returns ALT_AVALON_I2C_BUSY status if the ip is already - * enabled. In that case nothing is done. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \retval ALT_AVALON_I2C_BUSY - * Indicates the I2C controller is already enabled. - * \retval ALT_AVALON_I2C_SUCCESS - * Indicates the I2C controller has been successfully enabled. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_enable(ALT_AVALON_I2C_DEV_t *i2c_dev); - -/*! - * Returns ALT_AVALON_I2C_TRUE if the I2C controller is busy. The I2C controller is busy if - * not in the IDLE state - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \retval ALT_AVALON_I2C_TRUE - * Indicates the I2C controller is busy. - * \retval ALT_AVALON_I2C_FALSE - * Indicates the I2C controller is not busy. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_is_busy(ALT_AVALON_I2C_DEV_t *i2c_dev); - -/*! - * This function reads all available bytes from the receive FIFO, up to max_bytes_to_read. - * If max_bytes_to_read is 0, then all available bytes are read. - * - * This function is used to perform low level access to the data bytes - * received by the I2C controller and buffered in the receive FIFO. It - * may be used by master-receivers or slave receivers. - * - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param buffer - * [out]The buffer to receive the read data. - * - * \param max_bytes_to_read - * The maximum number of bytes to be read. If 0 then all available bytes are read. - * - * \param bytes_read - * [out] Pointer to variable indicating the number of bytes read. - */ -void alt_avalon_i2c_rx_read_available(ALT_AVALON_I2C_DEV_t *i2c_dev, alt_u8 *buffer, alt_u32 max_bytes_to_read, alt_u32 *bytes_read); - -/*! - * This function reads a single data byte from the receive FIFO. - * - * This function is used to perform low level access to the data bytes - * received by the I2C controller and buffered in the receive FIFO. It - * may be used by master-receivers or slave receivers. - * - * This function checks for valid data in the receive FIFO - * before reading the byte. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param val - * [out] The single data byte read from the receive FIFO. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_rx_read(ALT_AVALON_I2C_DEV_t *i2c_dev, alt_u8 *val); - -/*! - * This function writes the Transfer Command FIFO. - * - * This function is used to perform low level writes of data to the - * Transfer Command FIFO for transmission by the I2C controller. - * The value written includes the Stop and Start bits. - * - * This function checks for there to be space in Transfer Command FIFO - * before writing the register. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param val - * The data to write to the Transfer Command FIFO. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_cmd_write(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u8 val, - alt_u8 issue_restart, - alt_u8 issue_stop); - - -/*! @} */ - -/******************************************************************************/ -/*! \addtogroup TARGETADDRESSFUNCTIONS Target Address Functions - * - * The I2C target address is the address the I2C device being accessed will respond to. - * This is a 7 or 10 bit value. alt_avalon_i2c_send_address() will update the - * transfer command register with a value containing the target, direction, and restart - * bits. - * - * The alt_avalon_i2c_master_target_set() and alt_avalon_i2c_master_target_get() functions - * will set or get the target address that will be used in future I2C transactions. - * - * The target address must be set before doing any I2C functions. Once set it does not have - * to be set again unless changing the device being accessed. - * - * @{ - */ - -/*! - * This function sends the address and write or read command with optional - * restart bit to the Transfer Command Fifo. If the command - * fifo is full the command will wait until space is available. The command - * sequence will be 7 or 10 bit depending on the address mode setting. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param rw_bit - * The I2C Read (1) or Write(0) bit. - * - * \param issue_restart - * If issue_restart is 1, a restart is issued. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_send_address(ALT_AVALON_I2C_DEV_t *i2c_dev,const alt_u32 rw_bit,const alt_u8 issue_restart); - -/*! - * This function returns the current target address. - * - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param target_addr - * [out] The 7 or 10 bit slave target address. - * - */ -void alt_avalon_i2c_master_target_get(ALT_AVALON_I2C_DEV_t * i2c_dev, alt_u32 * target_addr); - -/*! - * This function updates the target address for any future I2C bus IO. - * - * This function does not wait for a bus idle state before changing the address. - * So is not suitable for being called from an interrupt routine. - * - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param target_addr - * The 7 or 10 bit slave target address. - * - */ -void alt_avalon_i2c_master_target_set(ALT_AVALON_I2C_DEV_t * i2c_dev, alt_u32 target_addr); -/*! @} */ - -/******************************************************************************/ -/*! \addtogroup Avalon I2C Transmit and Receive Functions - * - * The functions alt_avalon_i2c_master_transmit() and alt_avalon_i2c_master_receive() - * are the main functions for performing i2c transactions. These functions can be - * combined to create any combination of read-write operations within an I2C - * START to STOP sequence. - * There are also interrupt versions of the above functions, - * alt_avalon_i2c_master_transmit_using_interrupts() and alt_avalon_i2c_master_receive_using_interrupts(). - * Though the provided interrupt irq callback is functional and tested, it is mainly provided as an example - * starting point for a user to develop their own irq callback routine and to show how the - * user callback is registered and used. - * - * The above functions will return an ALT_AVALON_I2C_BUSY status if the ip is already enabled, - * and the function is being called with a START request (ie, restart parameter is not set). - * - * The functions alt_avalon_i2c_master_tx(), alt_avalon_i2c_master_rx(), and alt_avalon_i2c_master_tx_rx() - * are complete START to STOP sequence commands to simplify typical write and read operations and are - * basically wrappers for the alt_avalon_i2c_master_transmit() and alt_avalon_i2c_master_receive() functions. - * These wrapper functions will do automatic retry if the device is busy. - * - * @{ - */ - - -/*! - * This function transmits START followed by the I2C command - * byte(s). Then write requests are sent to fulfill the write request. The final - * transaction will issue a STOP. - * - * This API is not suitable for being called in an interrupt context as it may - * wait for certain controller states before completing. - * - * The target address must have been set before using this function. - * - * If an ALT_AVALON_I2C_ARB_LOST_ERR, ALT_AVALON_I2C_NACK_ERR, or ALT_AVALON_I2C_BUSY occurs the - * command will be retried. ALT_AVALON_I2C_NACK_ERR will occur when the slave - * device is not yet ready to accept more data. - * - * If the use_interrupts parameter is 1, then as soon as all bytes have been - * written to the command fifo this function will return. The interrupt handler - * will then handle waiting for the device to accept the data and will then complete the - * i2c transaction. To use this option the provided optional user interrupt handler - * callback must have been registered by calling the alt_avalon_i2c_register_optional_irq_handler - * function. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param buffer - * The data buffer to be sent. - * - * \param size - * The size of the data buffer to write to the I2C bus. - * - * \param use_interrupts - * The optional user interrupt handler callback will be used to handle - * sending the data. - * - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_tx(ALT_AVALON_I2C_DEV_t *i2c_dev, - const alt_u8 * buffer, - const alt_u32 size, - const alt_u8 use_interrupts); - - -/*! - * This function transmits START followed by the I2C command - * byte(s). Then read requests are sent to fulfill the read request. The final - * transaction will issue a STOP. - * - * This API is not suitable for being called in an interrupt context as it may - * wait for certain controller states before completing. - * - * The target address must have been set before using this function. - * - * If an ALT_AVALON_I2C_ARB_LOST_ERR, ALT_AVALON_I2C_NACK_ERR, ALT_AVALON_I2C_BUSY occurs the - * command will be retried. ALT_AVALON_I2C_NACK_ERR will occur when the slave - * device is not yet ready to accept more data. - * - * If the use_interrupts parameter is 1, then as soon as all cmd bytes have been - * written to the command fifo this function will return. The interrupt handler - * will then handle waiting for the device to send the rx data and will then complete the - * i2c transaction. To use this option the provided optional user interrupt handler - * callback must have been registered by calling the alt_avalon_i2c_register_optional_irq_handler - * function. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param buffer - * [out] The data buffer to be receive the i2c data. - * - * \param size - * The size of the data buffer to write to the I2C bus. - * - * \param use_interrupts - * The optional user interrupt handler callback will be used to handle - * receiving the data. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_rx(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u8 * buffer, - const alt_u32 size, - const alt_u8 use_interrupts); - - -/*! - * This function transmits START followed by the I2C command - * byte(s). Then write requests are sent to fulfill the write request. - * Then a RESTART is issued and read requests are sent until the read - * request is fulfilled. The final transaction will issue a STOP. - * - * This API is not suitable for being called in an interrupt context as it may - * wait for certain controller states before completing. - * - * The target address must have been set before using this function. - * - * If an ALT_AVALON_I2C_ARB_LOST_ERR, ALT_AVALON_I2C_NACK_ERR, or ALT_AVALON_I2C_BUSY occurs the - * command will be retried. ALT_AVALON_I2C_NACK_ERR will occur when the slave - * device is not yet ready to accept or send more data. - * - * This command will allow easy access of a device requiring an internal register - * address to be set before doing a read, for example an eeprom device. - * - * Example: If an eeprom requires a 2 byte address to be sent before doing a - * memory read, the tx buffer would contain the 2 byte address and the txsize - * would be set to 2. Then the rxbuffer will recieve the rxsize number of - * bytes to read from the eeprom as follows: - * To Read 0x10 bytes from eeprom at i2c address 0x51 into buffer: - * buffer[0]=2;buffer[1]=0; //set eeprom address 0x200 - * alt_avalon_i2c_master_tx_rx(i2c_ptr,buffer,2,buffer,0x10,0); - * - * Notice the tx and rx buffer can be the same buffer if desired. - * - * If the use_interrupts parameter is 1, then as soon as all cmd bytes have been - * written to the command fifo this function will return. The interrupt handler - * will then handle waiting for the device to send the rx data and will then complete the - * i2c transaction. To use this option the provided optional user interrupt handler - * callback must have been registered by calling the alt_avalon_i2c_register_optional_irq_handler - * function. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param txdata - * The send data buffer. - * - * \param txsize - * The size of the send data buffer to write to the I2C bus. - * - * \param rxdata - * [out] The receive data buffer. - * - * \param rxsize - * The size of the receive data buffer. - * - * \param use_interrupts - * The optional user interrupt handler callback will be used to handle - * sending and receiving the data. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_tx_rx(ALT_AVALON_I2C_DEV_t *i2c_dev, - const alt_u8 * txbuffer, - const alt_u32 txsize, - alt_u8 * rxbuffer, - const alt_u32 rxsize, - const alt_u8 use_interrupts); - -/*! - * This function transmits either a START or RESTART followed by the I2C command - * byte(s). Then write requests are sent to fulfill the write request. The final - * transaction may issue a STOP depending on the issue_stop parameter. - * - * This API is not suitable for being called in an interrupt context as it may - * wait for certain controller states before completing. - * - * The target address must have been set before using this function. - * - * If the command returns ALT_AVALON_I2C_ARB_LOST_ERR, ALT_AVALON_I2C_NACK_ERR, or - * ALT_AVALON_I2C_BUSY, - * the caller is responsible to do a retry (if desired) by calling the function again. - * To automatically do a complete write sequence with retry use the - * alt_avalon_i2c_master_tx() function. - * - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param data - * The data buffer to be sent. - * - * \param size - * The size of the data buffer to write to the I2C bus. - * - * \param issue_restart - * This parameter controls whether a RESTART or START is issued before - * the command byte is sent. If: - * * \b true \e a RESTART is issued before the command byte is sent. - * * \b false \e a START command is issued before the command byte(s) is sent. - * - * \param issue_stop - * This parameter controls whether a STOP is issued after the cmd data is - * sent. If: - * * \b true - STOP is issued after the final cmd byte is transmitted. - * * \b false - STOP is not issued. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_transmit(ALT_AVALON_I2C_DEV_t *i2c_dev, - const alt_u8 * data, - alt_u32 size, - const alt_u8 issue_restart, - const alt_u8 issue_stop); - - -/*! - * This function transmits either a START or RESTART followed by the I2C command - * byte(s). Then write requests are sent to fulfill the write request. The final - * transaction may issue a STOP depending on the issue_stop parameter. - * - * This API is not suitable for being called in an interrupt context as it may - * wait for certain controller states before completing. - * - * The target address must have been set before using this function. - * - * If the command returns ALT_AVALON_I2C_ARB_LOST_ERR or ALT_AVALON_I2C_NACK_ERR or ALT_AVALON_I2C_BUSY, - * the caller is responsible to do a retry (if desired) by calling the function again. - * To automatically do a complete write sequence with retry use the - * alt_avalon_i2c_master_tx() function with the retry option set. - * - * As soon as all cmd bytes have been - * written to the command fifo this function will return. The interrupt handler - * will then handle waiting for the device to accept the data completing the - * i2c transaction. To use this option the provided optional user interrupt handler - * callback must have been registered by calling the alt_avalon_i2c_register_optional_irq_handler - * function. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param data - * The data buffer to be sent. - * - * \param size - * The size of the data buffer to write to the I2C bus. - * - * \param issue_restart - * This parameter controls whether a RESTART or START is issued before - * the command byte is sent. If: - * * \b true \e a RESTART is issued before the command byte is sent. - * * \b false \e a START command is issued before the command byte(s) is sent. - * - * \param issue_stop - * This parameter controls whether a STOP is issued after the cmd data is - * sent. If: - * * \b true - STOP is issued after the final cmd byte is transmitted. - * * \b false - STOP is not issued. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_transmit_using_interrupts(ALT_AVALON_I2C_DEV_t *i2c_dev, - const alt_u8 * buffer, - alt_u32 size, - const alt_u8 issue_restart, - const alt_u8 issue_stop); - -/*! - * This function transmits either a START or RESTART followed by the I2C command - * byte(s). Then read requests are sent to fulfill the read request. The final - * transaction may issue a STOP depending on the issue_stop parameter. - * - * This API is not suitable for being called in an interrupt context as it may - * wait for certain controller states before completing. - * - * The target address must have been set before using this function. - * - * If the command returns ALT_AVALON_I2C_ARB_LOST_ERR, ALT_AVALON_I2C_NACK_ERR, - * or ALT_AVALON_I2C_BUSY - * the caller is responsible to do a retry (if desired) by repeating the i2c - * transaction from the call that issued the START, which may not be this one. - * To automatically do a complete write-read sequence with retry use the - * alt_avalon_i2c_master_tx_rx() function with the retry option set. - * - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param data - * [out] The data buffer to receive the requested \e size bytes. - * - * \param size - * The size of the data buffer to read from the RX FIFO. - * - * \param issue_restart - * This parameter controls whether a RESTART or START is issued before - * the command byte is sent. If: - * * \b true \e a RESTART is issued before the command byte is sent. - * * \b false \e a START command is issued before the command byte(s) is sent. - * - * \param issue_stop - * This parameter controls whether a STOP is issued after the cmd data is - * sent. If: - * * \b true - STOP is issued after the final cmd byte is transmitted. - * * \b false - STOP is not issued. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_receive(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u8 * data, - const alt_u32 size, - const alt_u8 issue_restart, - const alt_u8 issue_stop); - - -/*! - * This function transmits either a START or RESTART followed by the I2C command - * byte(s). Then read requests are sent to fulfill the read request. The final - * transaction may issue a STOP depending on the issue_stop parameter. - * - * This API is not suitable for being called in an interrupt context as it may - * wait for certain controller states before completing. - * - * The target address must have been set before using this function. - * - * If the command returns ALT_AVALON_I2C_ARB_LOST_ERR or ALT_AVALON_I2C_NACK_ERR or ALT_AVALON_I2C_BUSY - * the caller is responsible to do a retry (if desired) by repeating the i2c - * transaction from the call that issued the START, which may not be this one. - * To automatically do a complete write-read sequence with retry use the - * alt_avalon_i2c_master_tx_rx() function with the retry option set. - * - * As soon as all cmd bytes have been - * written to the command fifo this function will return. The interrupt handler - * will then handle waiting for the device to send the rx data and will then complete the - * i2c transaction. To use this option the provided optional user interrupt handler - * callback must have been registered by calling the alt_avalon_i2c_register_optional_irq_handler - * function. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param data - * [out] The data buffer to receive the requested \e size bytes. - * - * \param size - * The size of the data buffer to read from the RX FIFO. - * - * \param issue_restart - * This parameter controls whether a RESTART or START is issued before - * the command byte is sent. If: - * * \b true \e a RESTART is issued before the command byte is sent. - * * \b false \e a START command is issued before the command byte(s) is sent. - * - * \param issue_stop - * This parameter controls whether a STOP is issued after the cmd data is - * sent. If: - * * \b true - STOP is issued after the final cmd byte is transmitted. - * * \b false - STOP is not issued. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates successful status - * otherwise one of the ALT_AVALON_I2C_* status codes - * is returned. All failing return values are < 0. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_receive_using_interrupts(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u8 * buffer, - const alt_u32 size, - const alt_u8 issue_restart, - const alt_u8 issue_stop); - -/*! @} */ - -/******************************************************************************/ -/*! \addtogroup ALT_AVALON_I2C_INT Interrupt and Status Conditions - * - * The functions in this group provide management for the I2C controller status - * conditions and interrupts. - * - * Each I2C controller has a single combined interrupt output. - * The following events can generate an interrupt: - * * Arbitation lost - * * NACK Detected - * * Transmit Buffer Empty - * * Receive Buffer Full - * * Receive Overflow - * - * These interrupt status conditions may be monitored either by polling their - * status or by configuring interrupt handlers. - * - * Functions to get the current status, enable or disable (i.e. mass or unmask), - * and clear interrupt status conditions for the I2C controller are defined in - * this section. - * - * @{ - */ - -/*! - * This type enumerates interrupt status conditions for the I2C controller. - */ -typedef enum ALT_AVALON_I2C_ISR_e -{ - ALT_AVALON_I2C_STATUS_RX_OVER = 1UL << 4, - /*!< Set if the receive buffer is completely - * filled to capacity and an additional byte is - * received from an external I2C device. The I2C - * controller acknowledges this, but any data - * bytes received after the FIFO is full are - * discarded. Writing 1 to this field clears the - * contents to 0. - */ - ALT_AVALON_I2C_STATUS_ARBLOST_DET = 1UL << 3, - /*!< This bit is set to 1 when the i2c controller - * has lost the bus arbitration. Writing 1 to - * this field clears the contents to 0. - */ - ALT_AVALON_I2C_NACK_DET = 1UL << 2, - /*!< This bit is set to 1 when no acknowledgement - * (NACK) is recieved by the i2c controller. The - * MACK can be during the address or data transmission - * phase. Writing 1 to - * this field clears the contents to 0. - */ - ALT_AVALON_I2C_RX_READY = 1UL << 1, - /*!< This bit indicates the RX_DATA fifo level is - * equal or more than the RX_DATA fifo threshold. - * It is automatically cleared when the RX_DATA fifo - * level is less than the RX_DATA fifo threshold. - */ - ALT_AVALON_I2C_TX_READY = 1UL << 0, - /*!< This bit indicates the Transfer Command FIFO is ready - * for data transmission. This bit is asserted when the - * Transfer Command FIFO level is equal to or less than the - * Transfer Command FIFO threshold. - */ -} ALT_AVALON_I2C_STATUS_t; - -/* A structure to be used with the optional provided irq callback function*/ -typedef struct IRQ_DATA_s -{ - alt_u8 * buffer; - alt_u32 size; - alt_u32 irq_busy; -} IRQ_DATA_t; - - /*! - * Associate a user-specific routine with the i2c interrupt handler. - * If a callback is registered, all enabled ISR's will cause the callback to be executed. - * The callback runs as part of the interrupt service routine. - * - * An optional user callback routine is provided in this code and, if used, enables use - * of the alt_avalon_i2c_master_receive_using_interrupts and alt_avalon_i2c_master_transmit_using_interrupts - * functions. To register the optionally provided user callback use the alt_avalon_i2c_register_optional_irq_handler - * function. - * - * \param dev Pointer to i2c device (instance) structure. - * \param callback Pointer to callback routine to execute at interrupt level - * \param control For masking the source interruption and setting configuration - * \param context callback context - * - */ -void alt_avalon_i2c_register_callback( - ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_avalon_i2c_callback callback, - alt_u32 control, - void *context); - -/*! - * Associate the optional provided user interrupt callback routine with the i2c handler. - * This is a simple IRQ callback which allows I2C transaction functions to immedietly return - * while the optional callback handles receiving or transmitting the data to the device - * and completing the transaction. This optional callback uses a IRQ_DATA_t structure for - * irq data. The function alt_avalon_i2c_interrupt_transaction_status can be used to check - * for irq transaction complete, or for an transaction error. - * These optionally provided interrupt routines are functional, but are provided - * mainly for the purpose as working examples of using interrupts with the avalon i2c ip. - * A user may want to develop a more detailed irq callback routine tailored for specific - * device hardware. In that case, the user callback would be registered with the - * alt_avalon_i2c_register_callback function. - * - * Using this optionally provided user callback routine enables use - * of the alt_avalon_i2c_master_receive_using_interrupts and alt_avalon_i2c_master_transmit_using_interrupts - * functions. - * - * \param dev Pointer to i2c device (instance) structure. - * - * \param irq_data A structure used for interrupt handler data. - * Nothing needs to be set in this structure by the - * user. The storage merely has to be provided. - * The irq_busy variable can be used to check if the - * transaction is complete. In that case it will be 0. - */ -void alt_avalon_i2c_register_optional_irq_handler(ALT_AVALON_I2C_DEV_t *i2c_dev,IRQ_DATA_t * irq_data); - -/*! - * When an interrupt transaction has been initiated using the alt_avalon_i2c_master_tx, - * alt_avalon_i2c_master_rx, or alt_avalon_i2c_master_tx_rx function with the interrupt - * option set, or if using the alt_avalon_i2c_master_transmit_using_interrupts or - * alt_avalon_i2c_master_receive_using_interrupts functions, then this function can be - * used to check the status of that transaction. The only way to ensure error free - * back to back transactions is to use this function after every interrupt transaction - * to ensure the transaction had no errors and is complete, before starting the next transaction. - * Also, if an error is returned from this function, then the user must retry the i2c transaction. - * One reason an error may be returned is if the device is busy, which is likely to occur - * occasionally if doing back to back transactions. - * - * \param dev Pointer to i2c device (instance) structure. - * - * \retval ALT_AVALON_I2C_STATUS_CODE - * ALT_AVALON_I2C_SUCCESS indicates interrupt transaction is - * successfully completed. Another transaction can now be - * started. - * - * ALT_AVALON_I2C_BUSY indicates the interrupt transaction is still - * busy. - * - * ALT_AVALON_NACK_ERROR indicates the device did not ack. This is - * most likely because the device is busy with the previous transaction. - * The transaction must be retried. - * - * otherwise one of the other ALT_AVALON_I2C_* status codes - * is returned. The transaction must be retried. - * - * All failing return values are < 0. - * - */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_interrupt_transaction_status(ALT_AVALON_I2C_DEV_t *i2c_dev); - - /*! - * This reads the raw NACK status bit regardless of whether or not the corresponding - * interrupt is enabled. The function will update status if the NACK bit is set in the ISR reg/ - * Otherwise nothing is done. - * - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param status - * [in][out] Set to ALT_AVALON_I2C_NACK_ERR if the NACK bit - * in the ISR is set. Otherwise status is not modified. - * - */ -void alt_avalon_i2c_check_nack(ALT_AVALON_I2C_DEV_t *i2c_dev,ALT_AVALON_I2C_STATUS_CODE * status); - -/*! - * This reads the raw ARBLOST status bit regardless of whether or not the corresponding - * interrupt is enabled. This function will update status if the ARBLOST bit is set in the ISR reg - * Otherwise nothing is done. - * - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param status - * [in][out] Set to ALT_AVALON_I2C_ARB_LOST_ERR if the ARBLOST bit - * in the ISR is set. Otherwise, status is not modified. - * - */ -void alt_avalon_i2c_check_arblost(ALT_AVALON_I2C_DEV_t *i2c_dev,ALT_AVALON_I2C_STATUS_CODE * status); - -/*! - * Returns the current I2C controller interrupt status conditions. - * - * This function returns the current value of the I2C controller interrupt status - * register value which reflects the current I2C controller status conditions that - * are not disabled (i.e. masked). - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param status - * [out] A pointer to a bit mask of the active \ref ALT_AVALON_I2C_STATUS_t - * interrupt and status conditions. - * - */ -void alt_avalon_i2c_int_status_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u32 *status); - -/*! - * Returns the I2C controller raw interrupt status conditions irrespective of - * the interrupt status condition enablement state. - * - * This function returns the current value of the I2C controller raw interrupt - * status register value which reflects the current I2C controller status - * conditions regardless of whether they are disabled (i.e. masked) or not. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param status - * [out] A pointer to a bit mask of the active \ref ALT_AVALON_I2C_STATUS_t - * interrupt and status conditions. - * - * - */ -void alt_avalon_i2c_int_raw_status_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u32 *status); - -/*! - * Clears the specified I2C controller interrupt status conditions identified - * in the mask. - * - * This function clears one or more of the status conditions as contributors to - * the IRQ interrupt signal state. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param mask - * Specifies the interrupt status conditions to clear. \e mask - * is a mask of logically OR'ed \ref ALT_AVALON_I2C_STATUS_t values that - * designate the status conditions to clear. - * - */ -void alt_avalon_i2c_int_clear(ALT_AVALON_I2C_DEV_t *i2c_dev, const alt_u32 mask); - -/*! - * Disable the specified I2C controller interrupt status conditions identified in - * the mask. - * - * This function disables one or more of the status conditions as contributors to - * the \b ALT_INT_INTERRUPT_I2Cn_IRQ interrupt signal state. - * - * NOTE: A cleared bit for any status condition in the mask value does not have - * the effect of enabling it as a contributor to the IRQ interrupt signal state. - * The function alt_avalon_i2c_int_enable() is used to enable status source conditions. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param mask - * Specifies the status conditions to disable as interrupt source - * contributors. \e mask is a mask of logically OR'ed \ref - * ALT_AVALON_I2C_STATUS_t values that designate the status conditions to - * disable. - * - * - */ -void alt_avalon_i2c_int_disable(ALT_AVALON_I2C_DEV_t *i2c_dev, const alt_u32 mask); - -/*! - * Enable the specified I2C controller interrupt status conditions identified in - * the mask. - * - * This function enables one or more of the status conditions as contributors to - * the IRQ interrupt signal state. - * - * NOTE: A cleared bit for any status condition in the mask value does not have - * the effect of disabling it as a contributor to the IRQ interrupt signal state. - * The function alt_avalon_i2c_int_disable() is used to disable status source conditions. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param mask - * Specifies the status conditions to enable as interrupt source - * contributors. \e mask is a mask of logically OR'ed \ref - * ALT_AVALON_I2C_STATUS_t values that designate the status conditions to - * enable. - * - * - */ -void alt_avalon_i2c_int_enable(ALT_AVALON_I2C_DEV_t *i2c_dev, const alt_u32 mask); - -/*! - * Gets the Enabled Interrupts (reads the ISER register) - * - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param enabled_ints - * [out] A pointer to the variable to recieve the data. - * - * - */ -void alt_avalon_i2c_enabled_ints_get(ALT_AVALON_I2C_DEV_t *i2c_dev, alt_u32 * enabled_ints); - -/*! @} */ - -/******************************************************************************/ -/*! \addtogroup ALT_AVALON_I2C_RX_FIFO RX FIFO Management - * - * The receive FIFO has a configurable threshold value that controls the level of - * entries (or above) that sets the RX_READY status condition and triggers an - * interrupt. The valid ranges are 1, 1/4 full, 1/2 full, or full. - * - * @{ - */ - - /*! - * This type enumerates the RX_DATA_FIFO_THRESHOLD for the I2C controller. - */ -typedef enum ALT_AVALON_I2C_RX_DATA_FIFO_THRESHOLD_e -{ - ALT_AVALON_I2C_RX_DATA_FIFO_1_ENTRY = 0, - ALT_AVALON_I2C_RX_DATA_FIFO_1_4_FULL = 1, - ALT_AVALON_I2C_RX_DATA_FIFO_1_2_FULL = 2, - ALT_AVALON_I2C_RX_DATA_FIFO_FULL = 3, -} ALT_AVALON_I2C_RX_DATA_FIFO_THRESHOLD_t; - -/*! - * Gets the current receive FIFO threshold level value. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param threshold - * [out] The current threshold value. - * - * - */ -void alt_avalon_i2c_rx_fifo_threshold_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - ALT_AVALON_I2C_RX_DATA_FIFO_THRESHOLD_t *threshold); - -/*! - * Sets the current receive FIFO threshold level value. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param threshold - * The threshold value. - * - * - */ -void alt_avalon_i2c_rx_fifo_threshold_set(ALT_AVALON_I2C_DEV_t *i2c_dev, - const ALT_AVALON_I2C_RX_DATA_FIFO_THRESHOLD_t threshold); - -/*! @} */ - -/******************************************************************************/ -/*! \addtogroup ALT_AVALON_I2C_TFR_CMD Transfer Command FIFO Management - * - * The Transfer Command FIFO has a configurable threshold value that controls the level of - * entries (or below) that sets the TX_READY status condition and triggers an - * interrupt. The valid range is empty, 1/4 full, 1/2 full, and not full (at least 1 empty entry) - * - * @{ - */ - - /*! - * This type enumerates the TFR_CMD_FIFO_THRESHOLD for the I2C controller. - */ -typedef enum ALT_AVALON_I2C_TFR_CMD_FIFO_THRESHOLD_e -{ - ALT_AVALON_I2C_TFR_CMD_FIFO_EMPTY = 0, - ALT_AVALON_I2C_TFR_CMD_FIFO_1_4_FULL = 1, - ALT_AVALON_I2C_TFR_CMD_FIFO_1_2_FULL = 2, - ALT_AVALON_I2C_TFR_CMD_FIFO_NOT_FULL = 3, -} ALT_AVALON_I2C_TFR_CMD_FIFO_THRESHOLD_t; - -/*! - * Gets the current Transfer Command FIFO threshold level value. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param threshold - * [out] The current threshold value. - * - * - */ -void alt_avalon_i2c_tfr_cmd_fifo_threshold_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - ALT_AVALON_I2C_TFR_CMD_FIFO_THRESHOLD_t *threshold); - - -/*! - * Sets the current Transfer Command FIFO threshold level value. - * - * \param i2c_dev - * A pointer to the I2C controller device block instance. - * - * \param threshold - * The threshold value. - * - * - */ -void alt_avalon_i2c_tfr_cmd_fifo_threshold_set(ALT_AVALON_I2C_DEV_t *i2c_dev, - const ALT_AVALON_I2C_TFR_CMD_FIFO_THRESHOLD_t threshold); - - -/*! @} */ - -/*! @} */ - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALTERA_AVALON_I2C_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_i2c/HAL/src/CMakeLists.txt b/ext/hal/altera/drivers/altera_avalon_i2c/HAL/src/CMakeLists.txt deleted file mode 100644 index 2dc1ef73cd..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_i2c/HAL/src/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -zephyr_library() -zephyr_library_compile_definitions(${COMPILER}) -zephyr_library_sources(altera_avalon_i2c.c) -set_source_files_properties(altera_avalon_i2c.c - PROPERTIES COMPILE_DEFINITIONS "${COMPILER}") -set_source_files_properties(altera_avalon_i2c.c - PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized) # altera_avalon_i2c.c warns on uninitialized diff --git a/ext/hal/altera/drivers/altera_avalon_i2c/HAL/src/altera_avalon_i2c.c b/ext/hal/altera/drivers/altera_avalon_i2c/HAL/src/altera_avalon_i2c.c deleted file mode 100644 index ac76a378a3..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_i2c/HAL/src/altera_avalon_i2c.c +++ /dev/null @@ -1,1043 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2016 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ -#include -#include -#include -#include -#include "io.h" -#include "priv/alt_busy_sleep.h" -#include "sys/alt_errno.h" -#include "sys/alt_irq.h" -#include "sys/alt_stdio.h" -#include "sys/alt_alarm.h" -#include "altera_avalon_i2c.h" - - - -/* for all functions in this file, see the altera_avalon_i2c.h file for more complete function descriptions. */ - -/* optional irq callback */ -static void optional_irq_callback(void * context) -{ - int timeout=100000; - alt_u32 bytes_read; - - ALT_AVALON_I2C_DEV_t *i2c_dev = context; - IRQ_DATA_t *irq = i2c_dev->callback_context; - - if (irq->irq_busy==2) /*receive request*/ - { - alt_avalon_i2c_rx_read_available(i2c_dev, irq->buffer, irq->size, &bytes_read); - irq->size-=bytes_read; - irq->buffer+=bytes_read; - if (irq->size > 0) - { - /* clear ISR register content */ - alt_avalon_i2c_int_clear(i2c_dev,ALT_AVALON_I2C_ISR_ALL_CLEARABLE_INTS_MSK); - /* re-enable the RX_READY interrupt */ - alt_avalon_i2c_int_enable(i2c_dev,ALT_AVALON_I2C_ISER_RX_READY_EN_MSK); - return; - } - } - - /*transaction should be done so no or minimal looping should occur*/ - /*for a write, this code will only be reached after the cmd fifo is*/ - /*empty (sent). For a read this code will only be reached after all*/ - /*bytes have been received.*/ - while (alt_avalon_i2c_is_busy(i2c_dev)) - { - if (--timeout == 0) - { - break; - } - } - - /*disable the ip. The ip is disabled and enabled for each transaction.*/ - alt_avalon_i2c_disable(i2c_dev); - - irq->irq_busy=0; -} - -void alt_avalon_i2c_register_optional_irq_handler(ALT_AVALON_I2C_DEV_t *i2c_dev,IRQ_DATA_t * irq_data) -{ - irq_data->irq_busy=0; - alt_avalon_i2c_register_callback(i2c_dev,optional_irq_callback,0,irq_data); -} - -/* The list of registered i2c components */ -ALT_LLIST_HEAD(alt_avalon_i2c_list); - -/* Interrupt handler for the AVALON_I2C module. */ -/* Interrupts are not re-enabled in this handler */ -static void alt_avalon_i2c_irq(void *context) -{ - ALT_AVALON_I2C_DEV_t *dev = (ALT_AVALON_I2C_DEV_t *) context; - alt_irq_context cpu_sr; - - /*disable i2c interrupts*/ - alt_avalon_i2c_int_disable(dev,ALT_AVALON_I2C_ISR_ALLINTS_MSK); - - /* clear irq status */ - alt_avalon_i2c_int_clear(dev,ALT_AVALON_I2C_ISR_ALL_CLEARABLE_INTS_MSK); - - /* - * Other interrupts are explicitly disabled if callbacks - * are registered because there is no guarantee that they are - * pre-emption-safe. This allows the driver to support - * interrupt pre-emption. - */ - if(dev->callback) - { - cpu_sr = alt_irq_disable_all(); - dev->callback(dev); - alt_irq_enable_all(cpu_sr); - } - - return; -} - -/* Associate a user-specific routine with the i2c interrupt handler. */ -void alt_avalon_i2c_register_callback( - ALT_AVALON_I2C_DEV_t *dev, - alt_avalon_i2c_callback callback, - alt_u32 control, - void *context) -{ - dev->callback = callback; - dev->callback_context = context; - dev->control = control; - - return ; -} - - /* Initializes the I2C Module. This routine is called - * from the ALT_AVALON_I2C_INIT macro and is called automatically - * by alt_sys_init.c */ -void alt_avalon_i2c_init (ALT_AVALON_I2C_DEV_t *dev) -{ - extern alt_llist alt_avalon_i2c_list; - ALT_AVALON_I2C_MASTER_CONFIG_t cfg; - int error; - - /* disable ip */ - alt_avalon_i2c_disable(dev); - - /* Disable interrupts */ - alt_avalon_i2c_int_disable(dev,ALT_AVALON_I2C_ISR_ALLINTS_MSK); - - /* clear ISR register content */ - alt_avalon_i2c_int_clear(dev,ALT_AVALON_I2C_ISR_ALL_CLEARABLE_INTS_MSK); - - /* set the cmd fifo threshold */ - alt_avalon_i2c_tfr_cmd_fifo_threshold_set(dev,ALT_AVALON_I2C_TFR_CMD_FIFO_NOT_FULL); - - /* set the tx fifo threshold */ - alt_avalon_i2c_rx_fifo_threshold_set(dev,ALT_AVALON_I2C_RX_DATA_FIFO_FULL); - - /* set the default bus speed */ - cfg.speed_mode = ALT_AVALON_I2C_SPEED_STANDARD; - - /*set the address mode */ - cfg.addr_mode = ALT_AVALON_I2C_ADDR_MODE_7_BIT; - - /* set the bus speed */ - alt_avalon_i2c_master_config_speed_set(dev,&cfg,ALT_AVALON_I2C_SS_MAX_HZ); - - /* write the cfg information */ - alt_avalon_i2c_master_config_set(dev,&cfg); - - /* Register this instance of the i2c controller with HAL */ - alt_dev_llist_insert((alt_dev_llist*) dev, &alt_avalon_i2c_list); - - /* - * Creating semaphores used to protect access to the registers - * when running in a multi-threaded environment. - */ - error = ALT_SEM_CREATE (&dev->regs_lock, 1); - - if (!error) - { - /* Install IRQ handler */ - alt_ic_isr_register(dev->irq_controller_ID, dev->irq_ID, alt_avalon_i2c_irq, dev, 0x0); - } - else - { - alt_printf("failed to create semaphores\n"); - } - - return; - -} - -/* Retrieve a pointer to the i2c instance */ -ALT_AVALON_I2C_DEV_t* alt_avalon_i2c_open(const char* name) -{ - ALT_AVALON_I2C_DEV_t* dev = NULL; - - dev = (ALT_AVALON_I2C_DEV_t*) alt_find_dev (name, &alt_avalon_i2c_list); - - return dev; -} - -/* enable the avalon i2c ip */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_enable(ALT_AVALON_I2C_DEV_t *i2c_dev) -{ - IRQ_DATA_t *irq_data = i2c_dev->callback_context; - alt_u32 enable_status; - - /*if the ip is already enabled, return a busy status*/ - enable_status = (IORD_ALT_AVALON_I2C_CTRL(i2c_dev->i2c_base) & ALT_AVALON_I2C_CTRL_EN_MSK) >> ALT_AVALON_I2C_CTRL_EN_OFST; - if (enable_status) - { - return ALT_AVALON_I2C_BUSY; - } - - /*if the optional irq callback is registered ensure irq_busy is 0*/ - if (i2c_dev->callback == optional_irq_callback) - { - irq_data->irq_busy=0; - } - - /* enable ip */ - IORMW_ALT_AVALON_I2C_CTRL(i2c_dev->i2c_base,ALT_AVALON_I2C_CTRL_EN_MSK,ALT_AVALON_I2C_CTRL_EN_MSK); - - return ALT_AVALON_I2C_SUCCESS; -} - -/* disable the avalon i2c ip */ -void alt_avalon_i2c_disable(ALT_AVALON_I2C_DEV_t *i2c_dev) -{ - /* disable ip */ - IORMW_ALT_AVALON_I2C_CTRL(i2c_dev->i2c_base,0,ALT_AVALON_I2C_CTRL_EN_MSK); - -} - -/* populate the the master config structure from the register values */ -void alt_avalon_i2c_master_config_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - ALT_AVALON_I2C_MASTER_CONFIG_t* cfg) -{ - - cfg->addr_mode = i2c_dev->address_mode; - cfg->speed_mode = (IORD_ALT_AVALON_I2C_CTRL(i2c_dev->i2c_base) & ALT_AVALON_I2C_CTRL_BUS_SPEED_MSK) >> ALT_AVALON_I2C_CTRL_BUS_SPEED_OFST; - - cfg->scl_hcnt = (IORD_ALT_AVALON_I2C_SCL_HIGH(i2c_dev->i2c_base) & ALT_AVALON_I2C_SCL_HIGH_COUNT_PERIOD_MSK) >> ALT_AVALON_I2C_SCL_HIGH_COUNT_PERIOD_OFST; - cfg->scl_lcnt = (IORD_ALT_AVALON_I2C_SCL_LOW(i2c_dev->i2c_base) & ALT_AVALON_I2C_SCL_LOW_COUNT_PERIOD_MSK) >> ALT_AVALON_I2C_SCL_LOW_COUNT_PERIOD_OFST; - cfg->sda_cnt = (IORD_ALT_AVALON_I2C_SDA_HOLD(i2c_dev->i2c_base) & ALT_AVALON_I2C_SDA_HOLD_COUNT_PERIOD_MSK) >> ALT_AVALON_I2C_SDA_HOLD_COUNT_PERIOD_OFST; -} - -/* set the registers from the master config structure */ -void alt_avalon_i2c_master_config_set(ALT_AVALON_I2C_DEV_t *i2c_dev, - const ALT_AVALON_I2C_MASTER_CONFIG_t* cfg) -{ - i2c_dev->address_mode = cfg->addr_mode; - IORMW_ALT_AVALON_I2C_CTRL(i2c_dev->i2c_base,(cfg->speed_mode) << ALT_AVALON_I2C_CTRL_BUS_SPEED_OFST,ALT_AVALON_I2C_CTRL_BUS_SPEED_MSK); - - IOWR_ALT_AVALON_I2C_SCL_HIGH(i2c_dev->i2c_base,cfg->scl_hcnt); - IOWR_ALT_AVALON_I2C_SCL_LOW(i2c_dev->i2c_base,cfg->scl_lcnt); - IOWR_ALT_AVALON_I2C_SDA_HOLD(i2c_dev->i2c_base,cfg->sda_cnt); -} - -/* This function returns the speed based on parameters of the - * I2C master configuration. -*/ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_config_speed_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - const ALT_AVALON_I2C_MASTER_CONFIG_t* cfg, - alt_u32 * speed_in_hz) -{ - - if ((cfg->scl_lcnt == 0) || (cfg->scl_hcnt == 0)) - { - return ALT_AVALON_I2C_BAD_ARG; - } - - *speed_in_hz = (i2c_dev->ip_freq_in_hz) / (cfg->scl_lcnt + cfg->scl_hcnt); - - return ALT_AVALON_I2C_SUCCESS; -} - -/*This is a utility function that computes parameters for the I2C master - * configuration that best matches the speed requested. */ - ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_config_speed_set(ALT_AVALON_I2C_DEV_t *i2c_dev, - ALT_AVALON_I2C_MASTER_CONFIG_t * cfg, - alt_u32 speed_in_hz) -{ - alt_u32 scl_lcnt,scl_hcnt; - - /* If speed is not standard or fast return range error */ - if ((speed_in_hz > ALT_AVALON_I2C_FS_MAX_HZ) || (speed_in_hz < ALT_AVALON_I2C_SS_MIN_HZ) || (speed_in_hz == 0)) - { - return ALT_AVALON_I2C_RANGE; - } - - /* = / 2 * */ - scl_lcnt = (i2c_dev->ip_freq_in_hz) / (speed_in_hz << 1); - - /* adjust h/l by predetermined amount */ - scl_hcnt = scl_lcnt + ALT_AVALON_I2C_DIFF_LCNT_HCNT; - scl_lcnt = scl_lcnt - ALT_AVALON_I2C_DIFF_LCNT_HCNT; - - if (speed_in_hz > ALT_AVALON_I2C_FS_MIN_HZ) - { - cfg->speed_mode = ALT_AVALON_I2C_SPEED_FAST; - } - else - { - cfg->speed_mode = ALT_AVALON_I2C_SPEED_STANDARD; - } - - cfg->scl_lcnt = scl_lcnt; - cfg->scl_hcnt = scl_hcnt; - cfg->sda_cnt = scl_lcnt - (scl_lcnt / 2); - - return ALT_AVALON_I2C_SUCCESS; - -} - -/*Returns ALT_AVALON_I2C_TRUE if the I2C controller is busy. The I2C controller is busy if - * not in the IDLE state */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_is_busy(ALT_AVALON_I2C_DEV_t *i2c_dev) -{ - - if (IORD_ALT_AVALON_I2C_STATUS(i2c_dev->i2c_base) & ALT_AVALON_I2C_STATUS_CORE_STATUS_MSK) - { - return ALT_AVALON_I2C_TRUE; - } - - return ALT_AVALON_I2C_FALSE; -} - -/*Read all available bytes from the receive FIFO up to max_bytes_to_read. If max_bytes_to_read = 0 then read all available */ -void alt_avalon_i2c_rx_read_available(ALT_AVALON_I2C_DEV_t *i2c_dev, alt_u8 *buffer, alt_u32 max_bytes_to_read, alt_u32 *bytes_read) -{ - *bytes_read = 0; - - while (IORD_ALT_AVALON_I2C_RX_DATA_FIFO_LVL(i2c_dev->i2c_base)) - { - buffer[*bytes_read] = (alt_u8)IORD_ALT_AVALON_I2C_RX_DATA(i2c_dev->i2c_base); - *bytes_read+=1; - if ((*bytes_read == max_bytes_to_read) && (max_bytes_to_read != 0)) break; - } -} - -/*when a byte is available, reads a single data byte from the receive FIFO. */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_rx_read(ALT_AVALON_I2C_DEV_t *i2c_dev, alt_u8 *val) -{ - alt_u32 status = ALT_AVALON_I2C_SUCCESS; - alt_u32 timeout = 100000; - - - while (IORD_ALT_AVALON_I2C_RX_DATA_FIFO_LVL(i2c_dev->i2c_base) == 0) - { - if (timeout<10) alt_busy_sleep(10000); - if (--timeout == 0) - { - status = ALT_AVALON_I2C_TIMEOUT; - break; - } - } - - *val = (alt_u8)IORD_ALT_AVALON_I2C_RX_DATA(i2c_dev->i2c_base); - - return status; -} - -/* When space is available, writes the Transfer Command FIFO. */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_cmd_write(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u8 val, - alt_u8 issue_restart, - alt_u8 issue_stop) -{ - alt_u32 timeout = 10000; - ALT_AVALON_I2C_STATUS_CODE status = ALT_AVALON_I2C_SUCCESS; - - - while ((IORD_ALT_AVALON_I2C_ISR(i2c_dev->i2c_base) & ALT_AVALON_I2C_ISR_TX_READY_MSK)==0) - { - if (timeout<10) alt_busy_sleep(10000); - if (--timeout == 0) - { - return ALT_AVALON_I2C_TIMEOUT; - } - } - - IOWR_ALT_AVALON_I2C_TFR_CMD(i2c_dev->i2c_base,val | - (issue_restart << ALT_AVALON_I2C_TFR_CMD_STA_OFST) | - (issue_stop << ALT_AVALON_I2C_TFR_CMD_STO_OFST)); - - - /*check for nack error*/ - alt_avalon_i2c_check_nack(i2c_dev,&status); - - /*check for arb lost*/ - alt_avalon_i2c_check_arblost(i2c_dev,&status); - - return status; -} - -/*send 7 or 10 bit i2c address to cmd fifo*/ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_send_address(ALT_AVALON_I2C_DEV_t *i2c_dev, - const alt_u32 rw_bit, - const alt_u8 issue_restart) -{ - alt_u32 status; - - if (i2c_dev->address_mode == ALT_AVALON_I2C_ADDR_MODE_10_BIT) - { - status = alt_avalon_i2c_cmd_write(i2c_dev,(((i2c_dev->master_target_address | TARGET_ADDR_MASK_10BIT) >> 7) & 0xfe) | rw_bit,issue_restart,ALT_AVALON_I2C_NO_STOP); - status = alt_avalon_i2c_cmd_write(i2c_dev,i2c_dev->master_target_address & 0xff,ALT_AVALON_I2C_NO_RESTART,ALT_AVALON_I2C_NO_STOP); - } - else - { - status = alt_avalon_i2c_cmd_write(i2c_dev,(i2c_dev->master_target_address << 1) | rw_bit,issue_restart,ALT_AVALON_I2C_NO_STOP); - } - - return status; -} - -/* This function returns the current target address. */ -void alt_avalon_i2c_master_target_get(ALT_AVALON_I2C_DEV_t * i2c_dev, alt_u32 * target_addr) -{ - *target_addr=i2c_dev->master_target_address; -} - -/* This function updates the target address for any upcoming I2C bus IO. */ -void alt_avalon_i2c_master_target_set(ALT_AVALON_I2C_DEV_t * i2c_dev, alt_u32 target_addr) -{ - i2c_dev->master_target_address=target_addr; -} - -/*if nack detected, status is set to ALT_AVALON_I2C_NACK_ERR*/ -void alt_avalon_i2c_check_nack(ALT_AVALON_I2C_DEV_t *i2c_dev,ALT_AVALON_I2C_STATUS_CODE * status) -{ - if (IORD_ALT_AVALON_I2C_ISR(i2c_dev->i2c_base) & ALT_AVALON_I2C_ISR_NACK_DET_MSK) - { - *status=ALT_AVALON_I2C_NACK_ERR; - } -} - -/*if arb lost is detected, status is set to ALT_AVALON_I2C_ARB_LOST_ERR*/ -void alt_avalon_i2c_check_arblost(ALT_AVALON_I2C_DEV_t *i2c_dev,ALT_AVALON_I2C_STATUS_CODE * status) -{ - if (IORD_ALT_AVALON_I2C_ISR(i2c_dev->i2c_base) & ALT_AVALON_I2C_ISR_ARBLOST_DET_MSK) - { - *status=ALT_AVALON_I2C_ARB_LOST_ERR; - } -} - -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_interrupt_transaction_status(ALT_AVALON_I2C_DEV_t *i2c_dev) -{ - ALT_AVALON_I2C_STATUS_CODE status = ALT_AVALON_I2C_SUCCESS; - IRQ_DATA_t *irq_data = i2c_dev->callback_context; - alt_u32 timeout=10000 * irq_data->size + 10000; - alt_u32 saveints,temp_bytes_read; - - /* save current enabled interrupts */ - alt_avalon_i2c_enabled_ints_get(i2c_dev,&saveints); - - /* disable the enabled interrupts */ - alt_avalon_i2c_int_disable(i2c_dev,saveints); - - alt_avalon_i2c_check_nack(i2c_dev,&status); - - if (status!=ALT_AVALON_I2C_SUCCESS) - { - if (irq_data->irq_busy) - { - while (alt_avalon_i2c_is_busy(i2c_dev)) - { - if (timeout<10) alt_busy_sleep(10000); - if (--timeout == 0) - { - status = ALT_AVALON_I2C_TIMEOUT; - break; - } - } - - /*clear any rx entries */ - alt_avalon_i2c_rx_read_available(i2c_dev, irq_data->buffer,0,&temp_bytes_read); - - /*disable the ip. The ip is disabled and enabled for each transaction. */ - alt_avalon_i2c_disable(i2c_dev); - - /*abort the transaction */ - irq_data->irq_busy=0; - } - - /*return nack error so transaction can be retried*/ - return status; - } - - if (irq_data->irq_busy) - { - /*re-enable the interrupts*/ - alt_avalon_i2c_int_enable(i2c_dev,saveints); - - /*return transaction still busy*/ - return ALT_AVALON_I2C_BUSY; - } - - /*return transaction completed status, ok to do another transaction*/ - return ALT_AVALON_I2C_SUCCESS; -} - -/*transmit function with retry and optionally interrupts*/ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_tx(ALT_AVALON_I2C_DEV_t *i2c_dev, - const alt_u8 * buffer, - const alt_u32 size, - const alt_u8 use_interrupts) -{ - ALT_AVALON_I2C_STATUS_CODE status; - alt_u32 retry=10000; - - while (retry--) - { - if (retry<10) alt_busy_sleep(10000); - if (use_interrupts) - { - status = alt_avalon_i2c_master_transmit_using_interrupts(i2c_dev, buffer, size, ALT_AVALON_I2C_NO_RESTART, ALT_AVALON_I2C_STOP); - } - else - { - status = alt_avalon_i2c_master_transmit(i2c_dev, buffer, size, ALT_AVALON_I2C_NO_RESTART, ALT_AVALON_I2C_STOP); - } - if ((status==ALT_AVALON_I2C_ARB_LOST_ERR) || (status==ALT_AVALON_I2C_NACK_ERR) || (status==ALT_AVALON_I2C_BUSY)) continue; - break; - } - - return status; -} - -/*receive function with retry and optionally interrupts*/ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_rx(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u8 * buffer, - const alt_u32 size, - const alt_u8 use_interrupts) -{ - ALT_AVALON_I2C_STATUS_CODE status; - alt_u32 retry=10000; - - if (use_interrupts) - { - while (retry--) - { - if (retry<10) alt_busy_sleep(10000); - status = alt_avalon_i2c_master_receive_using_interrupts(i2c_dev, buffer, size, ALT_AVALON_I2C_NO_RESTART, ALT_AVALON_I2C_STOP); - if ((status==ALT_AVALON_I2C_ARB_LOST_ERR) || (status==ALT_AVALON_I2C_NACK_ERR) || (status==ALT_AVALON_I2C_BUSY)) continue; - break; - } - } - else - { - while (retry--) - { - if (retry<10) alt_busy_sleep(10000); - status = alt_avalon_i2c_master_receive(i2c_dev, buffer, size, ALT_AVALON_I2C_NO_RESTART, ALT_AVALON_I2C_STOP); - if ((status==ALT_AVALON_I2C_ARB_LOST_ERR) || (status==ALT_AVALON_I2C_NACK_ERR) || (status==ALT_AVALON_I2C_BUSY)) continue; - break; - } - } - - return status; -} - - -/*transmit, restart, recieve function using retry and optionally interrupts */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_tx_rx(ALT_AVALON_I2C_DEV_t *i2c_dev, - const alt_u8 * txbuffer, - const alt_u32 txsize, - alt_u8 * rxbuffer, - const alt_u32 rxsize, - const alt_u8 use_interrupts) -{ - ALT_AVALON_I2C_STATUS_CODE status; - alt_u32 retry=10000; - - if (use_interrupts) - { - while (retry--) - { - if (retry<10) alt_busy_sleep(10000); - status = alt_avalon_i2c_master_transmit_using_interrupts(i2c_dev, txbuffer, txsize, ALT_AVALON_I2C_NO_RESTART, ALT_AVALON_I2C_NO_STOP); - if ((status==ALT_AVALON_I2C_ARB_LOST_ERR) || (status==ALT_AVALON_I2C_NACK_ERR) || (status==ALT_AVALON_I2C_BUSY)) continue; - - status = alt_avalon_i2c_master_receive_using_interrupts(i2c_dev, rxbuffer, rxsize, ALT_AVALON_I2C_RESTART, ALT_AVALON_I2C_STOP); - if ((status==ALT_AVALON_I2C_ARB_LOST_ERR) || (status==ALT_AVALON_I2C_NACK_ERR) || (status==ALT_AVALON_I2C_BUSY)) continue; - - break; - } - } - else - { - while (retry--) - { - if (retry<10) alt_busy_sleep(10000); - status = alt_avalon_i2c_master_transmit(i2c_dev, txbuffer, txsize, ALT_AVALON_I2C_NO_RESTART, ALT_AVALON_I2C_NO_STOP); - if ((status==ALT_AVALON_I2C_ARB_LOST_ERR) || (status==ALT_AVALON_I2C_NACK_ERR) || (status==ALT_AVALON_I2C_BUSY)) continue; - - status = alt_avalon_i2c_master_receive(i2c_dev, rxbuffer, rxsize, ALT_AVALON_I2C_RESTART, ALT_AVALON_I2C_STOP); - if ((status==ALT_AVALON_I2C_ARB_LOST_ERR) || (status==ALT_AVALON_I2C_NACK_ERR) || (status==ALT_AVALON_I2C_BUSY)) continue; - - break; - } - } - - return status; -} - -/*This function issues a write command and transmits data to the I2C bus. */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_transmit(ALT_AVALON_I2C_DEV_t *i2c_dev, - const alt_u8 * buffer, - alt_u32 size, - const alt_u8 issue_restart, - const alt_u8 issue_stop) -{ - ALT_AVALON_I2C_STATUS_CODE status = ALT_AVALON_I2C_SUCCESS; - alt_u32 timeout=size * 10000; - - if (size==0) - { - return ALT_AVALON_I2C_SUCCESS; - } - - /*if a new transaction, enable ip and clear int status*/ - if (!issue_restart) - { - /*enable the ip. The ip is disabled and enabled for each transaction.*/ - status = alt_avalon_i2c_enable(i2c_dev); - if (status != ALT_AVALON_I2C_SUCCESS) - { - return status; - } - - /*Clear the ISR reg*/ - alt_avalon_i2c_int_clear(i2c_dev,ALT_AVALON_I2C_ISR_ALL_CLEARABLE_INTS_MSK); - } - - /*Start Write, transmit address. */ - status = alt_avalon_i2c_send_address(i2c_dev,ALT_AVALON_I2C_WRITE,issue_restart); - - if (status == ALT_AVALON_I2C_SUCCESS) - { - while ((size > 1) && (status == ALT_AVALON_I2C_SUCCESS)) - { - status = alt_avalon_i2c_cmd_write(i2c_dev, *buffer, ALT_AVALON_I2C_NO_RESTART, ALT_AVALON_I2C_NO_STOP); - - ++buffer; - --size; - } - - /* Last byte */ - if (status == ALT_AVALON_I2C_SUCCESS) - { - status = alt_avalon_i2c_cmd_write(i2c_dev, *buffer, ALT_AVALON_I2C_NO_RESTART, issue_stop); - - ++buffer; - --size; - } - } - - /*if end of transaction, wait until the ip is idle then disable the ip*/ - if ((issue_stop) || (status != ALT_AVALON_I2C_SUCCESS)) - { - - while (alt_avalon_i2c_is_busy(i2c_dev)) - { - if (timeout<10) alt_busy_sleep(10000); - if (--timeout == 0) - { - status = ALT_AVALON_I2C_TIMEOUT; - break; - } - } - - /*check for a nack error*/ - alt_avalon_i2c_check_nack(i2c_dev,&status); - - /*disable the ip. The ip is disabled and enabled for each transaction.*/ - alt_avalon_i2c_disable(i2c_dev); - } - - - return status; -} - -/*This function issues a write command and transmits data to the I2C bus */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_transmit_using_interrupts(ALT_AVALON_I2C_DEV_t *i2c_dev, - const alt_u8 * buffer, - alt_u32 size, - const alt_u8 issue_restart, - const alt_u8 issue_stop) -{ - ALT_AVALON_I2C_STATUS_CODE status = ALT_AVALON_I2C_SUCCESS; - alt_u32 timeout=size*10000; - IRQ_DATA_t *irq_data = i2c_dev->callback_context; - - if (size==0) - { - return ALT_AVALON_I2C_SUCCESS; - } - - /*IS the optional interrupt handler registered??*/ - if (i2c_dev->callback != optional_irq_callback) - { - return ALT_AVALON_I2C_BAD_ARG; - } - - /*if a new transaction, enable ip and clear int status*/ - if (!issue_restart) - { - /*enable the ip. The ip is disabled and enabled for each transaction.*/ - status = alt_avalon_i2c_enable(i2c_dev); - if (status != ALT_AVALON_I2C_SUCCESS) - { - return status; - } - - /*Clear the ISR reg*/ - alt_avalon_i2c_int_clear(i2c_dev,ALT_AVALON_I2C_ISR_ALL_CLEARABLE_INTS_MSK); - } - - /*Start Write, transmit address. */ - status = alt_avalon_i2c_send_address(i2c_dev,ALT_AVALON_I2C_WRITE,issue_restart); - - if (status == ALT_AVALON_I2C_SUCCESS) - { - while ((size > 1) && (status == ALT_AVALON_I2C_SUCCESS)) - { - status = alt_avalon_i2c_cmd_write(i2c_dev, *buffer, ALT_AVALON_I2C_NO_RESTART, ALT_AVALON_I2C_NO_STOP); - - ++buffer; - --size; - } - - /* Last byte */ - if (status == ALT_AVALON_I2C_SUCCESS) - { - status = alt_avalon_i2c_cmd_write(i2c_dev, *buffer, ALT_AVALON_I2C_NO_RESTART, issue_stop); - - ++buffer; - --size; - } - } - - /*if error, wait until the ip is idle then disable the ip*/ - if (status != ALT_AVALON_I2C_SUCCESS) - { - - while (alt_avalon_i2c_is_busy(i2c_dev)) - { - if (timeout<10) alt_busy_sleep(10000); - if (--timeout == 0) - { - status = ALT_AVALON_I2C_TIMEOUT; - break; - } - } - - /*disable the ip. The ip is disabled and enabled for each transaction.*/ - alt_avalon_i2c_disable(i2c_dev); - } - else - { - if (issue_stop) - { - /* clear ISR register content */ - alt_avalon_i2c_int_clear(i2c_dev,ALT_AVALON_I2C_ISR_ALL_CLEARABLE_INTS_MSK); - /* set the cmd fifo threshold */ - alt_avalon_i2c_tfr_cmd_fifo_threshold_set(i2c_dev,ALT_AVALON_I2C_TFR_CMD_FIFO_EMPTY); - /* set the interrupt transaction busy bit */ - irq_data->irq_busy=1; - /* enable the TX_READY interrupt */ - alt_avalon_i2c_int_enable(i2c_dev,ALT_AVALON_I2C_ISER_TX_READY_EN_MSK); - } - } - - return status; -} - -/*This function receives one or more data bytes transmitted from a slave in - * response to read requests issued from this master. */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_receive(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u8 * buffer, - const alt_u32 size, - const alt_u8 issue_restart, - const alt_u8 issue_stop) -{ - ALT_AVALON_I2C_STATUS_CODE status = ALT_AVALON_I2C_SUCCESS; - alt_u32 timeout; - alt_u32 bytes_read=0; - alt_u32 bytes_written=0; - alt_u32 temp_bytes_read; - - if (size==0) - { - return ALT_AVALON_I2C_SUCCESS; - } - - /*if a new transaction, enable ip and clear int status*/ - if (!issue_restart) - { - /*enable the ip. The ip is disabled and enabled for each transaction.*/ - status = alt_avalon_i2c_enable(i2c_dev); - if (status != ALT_AVALON_I2C_SUCCESS) - { - return status; - } - - /*Clear the ISR reg*/ - alt_avalon_i2c_int_clear(i2c_dev,ALT_AVALON_I2C_ISR_ALL_CLEARABLE_INTS_MSK); - } - - /*Start Write, transmit address. */ - status = alt_avalon_i2c_send_address(i2c_dev,ALT_AVALON_I2C_READ,issue_restart); - - if (status == ALT_AVALON_I2C_SUCCESS) - { - while ((bytes_written < (size-1)) && (status == ALT_AVALON_I2C_SUCCESS)) - { - status = alt_avalon_i2c_cmd_write(i2c_dev, 0, ALT_AVALON_I2C_NO_RESTART, ALT_AVALON_I2C_NO_STOP); - bytes_written++; - if (status == ALT_AVALON_I2C_SUCCESS) - { - alt_avalon_i2c_rx_read_available(i2c_dev, buffer,0,&temp_bytes_read); - buffer+=temp_bytes_read; - bytes_read+=temp_bytes_read; - } - } - - /* Last byte */ - if (status == ALT_AVALON_I2C_SUCCESS) - { - status = alt_avalon_i2c_cmd_write(i2c_dev, 0, ALT_AVALON_I2C_NO_RESTART, issue_stop); - } - } - - while ((bytes_read < size) && (status==ALT_AVALON_I2C_SUCCESS)) - { - status=alt_avalon_i2c_rx_read(i2c_dev, buffer); - buffer++; - bytes_read++; - } - - /*if end of transaction, wait until the ip is idle then disable the ip*/ - if ((issue_stop) || (status != ALT_AVALON_I2C_SUCCESS)) - { - timeout=10000 * size; - while (alt_avalon_i2c_is_busy(i2c_dev)) - { - if (timeout<10) alt_busy_sleep(10000); - if (--timeout == 0) - { - status = ALT_AVALON_I2C_TIMEOUT; - break; - } - } - - /*check for nack error*/ - alt_avalon_i2c_check_nack(i2c_dev,&status); - - /*disable the ip. The ip is disabled and enabled for each transaction.*/ - alt_avalon_i2c_disable(i2c_dev); - } - - return status; -} - -/*This function receives one or more data bytes transmitted from a slave in - * response to read requests issued from this master. Uses the optional interrupt routine. */ -ALT_AVALON_I2C_STATUS_CODE alt_avalon_i2c_master_receive_using_interrupts(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u8 * buffer, - const alt_u32 size, - const alt_u8 issue_restart, - const alt_u8 issue_stop) -{ - ALT_AVALON_I2C_STATUS_CODE status = ALT_AVALON_I2C_SUCCESS; - IRQ_DATA_t *irq_data = i2c_dev->callback_context; - alt_u32 timeout; - alt_u32 bytes_written=0; - - if (size==0) - { - return ALT_AVALON_I2C_SUCCESS; - } - - /*Is the optional interrupt handler registered??*/ - if (i2c_dev->callback != optional_irq_callback) - { - return ALT_AVALON_I2C_BAD_ARG; - } - - /*if a new transaction, enable ip and clear int status*/ - if (!issue_restart) - { - /*enable the ip. The ip is disabled and enabled for each transaction.*/ - status = alt_avalon_i2c_enable(i2c_dev); - if (status != ALT_AVALON_I2C_SUCCESS) - { - return status; - } - - /*Clear the ISR reg*/ - alt_avalon_i2c_int_clear(i2c_dev,ALT_AVALON_I2C_ISR_ALL_CLEARABLE_INTS_MSK); - - } - - /*Start Write, transmit address. */ - status = alt_avalon_i2c_send_address(i2c_dev,ALT_AVALON_I2C_READ,issue_restart); - - if (status == ALT_AVALON_I2C_SUCCESS) - { - while ((bytes_written < (size-1)) && (status == ALT_AVALON_I2C_SUCCESS)) - { - status = alt_avalon_i2c_cmd_write(i2c_dev, 0, ALT_AVALON_I2C_NO_RESTART, ALT_AVALON_I2C_NO_STOP); - bytes_written++; - } - - /* Last byte */ - if (status == ALT_AVALON_I2C_SUCCESS) - { - status = alt_avalon_i2c_cmd_write(i2c_dev, 0, ALT_AVALON_I2C_NO_RESTART, issue_stop); - } - } - - /*if error, wait until the ip is idle then disable the ip*/ - if (status != ALT_AVALON_I2C_SUCCESS) - { - timeout=10000 * size; - while (alt_avalon_i2c_is_busy(i2c_dev)) - { - if (timeout<10) alt_busy_sleep(10000); - if (--timeout == 0) - { - status = ALT_AVALON_I2C_TIMEOUT; - break; - } - } - - /*disable the ip. The ip is disabled and enabled for each transaction.*/ - alt_avalon_i2c_disable(i2c_dev); - } - else - { - if (issue_stop) - { - /* clear ISR register content */ - alt_avalon_i2c_int_clear(i2c_dev,ALT_AVALON_I2C_ISR_ALL_CLEARABLE_INTS_MSK); - /* set the cmd fifo threshold */ - alt_avalon_i2c_rx_fifo_threshold_set(i2c_dev,ALT_AVALON_I2C_RX_DATA_FIFO_1_ENTRY); - /* set the interrupt transaction busy bit 2 = receive */ - irq_data->irq_busy=2; - - irq_data->buffer = buffer; - irq_data->size = size; - - /* enable the RX_READY interrupt */ - alt_avalon_i2c_int_enable(i2c_dev,ALT_AVALON_I2C_ISER_RX_READY_EN_MSK); - } - } - - return status; -} - -/* Returns the current I2C controller interrupt status conditions. */ -void alt_avalon_i2c_int_status_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u32 *status) -{ - *status = IORD_ALT_AVALON_I2C_ISR(i2c_dev->i2c_base) & IORD_ALT_AVALON_I2C_ISER(i2c_dev->i2c_base); -} - -/*Returns the I2C controller raw interrupt status conditions irrespective of - * the interrupt status condition enablement state. */ -void alt_avalon_i2c_int_raw_status_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - alt_u32 *status) -{ - *status = IORD_ALT_AVALON_I2C_ISR(i2c_dev->i2c_base); -} - -/*Clears the specified I2C controller interrupt status conditions identified - * in the mask. */ -void alt_avalon_i2c_int_clear(ALT_AVALON_I2C_DEV_t *i2c_dev, const alt_u32 mask) -{ - IOWR_ALT_AVALON_I2C_ISR(i2c_dev->i2c_base,mask); -} - -/*Disable the specified I2C controller interrupt status conditions identified in - * the mask. */ -void alt_avalon_i2c_int_disable(ALT_AVALON_I2C_DEV_t *i2c_dev, const alt_u32 mask) -{ - alt_u32 enabled_ints; - - alt_avalon_i2c_enabled_ints_get(i2c_dev,&enabled_ints); - enabled_ints &= (~mask); - IOWR_ALT_AVALON_I2C_ISER(i2c_dev->i2c_base,ALT_AVALON_I2C_ISR_ALLINTS_MSK & enabled_ints); -} - -/*Enable the specified I2C controller interrupt status conditions identified in - * the mask. */ -void alt_avalon_i2c_int_enable(ALT_AVALON_I2C_DEV_t *i2c_dev, const alt_u32 mask) -{ - alt_u32 enabled_ints; - - alt_avalon_i2c_enabled_ints_get(i2c_dev,&enabled_ints); - enabled_ints |= mask; - IOWR_ALT_AVALON_I2C_ISER(i2c_dev->i2c_base,ALT_AVALON_I2C_ISR_ALLINTS_MSK & enabled_ints); -} - -/*gets the enabled i2c interrupts. */ -void alt_avalon_i2c_enabled_ints_get(ALT_AVALON_I2C_DEV_t *i2c_dev, alt_u32 * enabled_ints) -{ - *enabled_ints=IORD_ALT_AVALON_I2C_ISER(i2c_dev->i2c_base) & ALT_AVALON_I2C_ISR_ALLINTS_MSK; -} - -/*Gets the current receive FIFO threshold level value. */ -void alt_avalon_i2c_rx_fifo_threshold_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - ALT_AVALON_I2C_RX_DATA_FIFO_THRESHOLD_t *threshold) -{ - *threshold = (IORD_ALT_AVALON_I2C_CTRL(i2c_dev->i2c_base) & ALT_AVALON_I2C_CTRL_RX_DATA_FIFO_THD_MSK) >> ALT_AVALON_I2C_CTRL_RX_DATA_FIFO_THD_OFST; -} - -/*sets the current receive FIFO threshold level value. */ -void alt_avalon_i2c_rx_fifo_threshold_set(ALT_AVALON_I2C_DEV_t *i2c_dev, - const ALT_AVALON_I2C_RX_DATA_FIFO_THRESHOLD_t threshold) -{ - IORMW_ALT_AVALON_I2C_CTRL(i2c_dev->i2c_base,threshold << ALT_AVALON_I2C_CTRL_RX_DATA_FIFO_THD_OFST,ALT_AVALON_I2C_CTRL_RX_DATA_FIFO_THD_MSK); -} - -/*Gets the current Transfer Command FIFO threshold level value.*/ -void alt_avalon_i2c_tfr_cmd_fifo_threshold_get(ALT_AVALON_I2C_DEV_t *i2c_dev, - ALT_AVALON_I2C_TFR_CMD_FIFO_THRESHOLD_t *threshold) -{ - *threshold = (IORD_ALT_AVALON_I2C_CTRL(i2c_dev->i2c_base) & ALT_AVALON_I2C_CTRL_TFR_CMD_FIFO_THD_MSK) >> ALT_AVALON_I2C_CTRL_TFR_CMD_FIFO_THD_OFST; -} - -/*Sets the current Transfer Command FIFO threshold level value.*/ -void alt_avalon_i2c_tfr_cmd_fifo_threshold_set(ALT_AVALON_I2C_DEV_t *i2c_dev, - const ALT_AVALON_I2C_TFR_CMD_FIFO_THRESHOLD_t threshold) -{ - IORMW_ALT_AVALON_I2C_CTRL(i2c_dev->i2c_base,threshold << ALT_AVALON_I2C_CTRL_TFR_CMD_FIFO_THD_OFST,ALT_AVALON_I2C_CTRL_TFR_CMD_FIFO_THD_MSK); -} diff --git a/ext/hal/altera/drivers/altera_avalon_i2c/inc/altera_avalon_i2c_regs.h b/ext/hal/altera/drivers/altera_avalon_i2c/inc/altera_avalon_i2c_regs.h deleted file mode 100644 index f96c881137..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_i2c/inc/altera_avalon_i2c_regs.h +++ /dev/null @@ -1,150 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2016 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALT_AVALON_I2C_REGS_H__ -#define __ALT_AVALON_I2C_REGS_H__ - -#include - -#define IORMW(base, reg, data, mask) IOWR(base,reg,(IORD(base,reg) & (~mask)) | (data & mask)) - -#define ALT_AVALON_I2C_TFR_CMD_REG 0 -#define IOADDR_ALT_AVALON_I2C_TFR_CMD(base) __IO_CALC_ADDRESS_NATIVE(base, ALT_AVALON_I2C_TFR_CMD_REG) -#define IORD_ALT_AVALON_I2C_TFR_CMD(base) IORD(base, ALT_AVALON_I2C_TFR_CMD_REG) -#define IOWR_ALT_AVALON_I2C_TFR_CMD(base, data) IOWR(base, ALT_AVALON_I2C_TFR_CMD_REG, data) -#define ALT_AVALON_I2C_TFR_CMD_STA_OFST (9) -#define ALT_AVALON_I2C_TFR_CMD_STA_MSK (1 << ALT_AVALON_I2C_TFR_CMD_STA_OFST) -#define ALT_AVALON_I2C_TFR_CMD_STO_OFST (8) -#define ALT_AVALON_I2C_TFR_CMD_STO_MSK (1 << ALT_AVALON_I2C_TFR_CMD_STO_OFST) -#define ALT_AVALON_I2C_TFR_CMD_AD_OFST (1) -#define ALT_AVALON_I2C_TFR_CMD_AD_MSK (0x7f << ALT_AVALON_I2C_TFR_CMD_AD_OFST) -#define ALT_AVALON_I2C_TFR_CMD_RW_D_OFST (0) -#define ALT_AVALON_I2C_TFR_CMD_RW_D_MSK (1 << ALT_AVALON_I2C_TFR_CMD_RW_D_OFST) -#define ALT_AVALON_I2C_TFR_CMD_ALL_BITS_MSK (0x3ff) - -#define ALT_AVALON_I2C_RX_DATA_REG 1 -#define IOADDR_ALT_AVALON_I2C_RX_DATA(base) __IO_CALC_ADDRESS_NATIVE(base, ALT_AVALON_I2C_RX_DATA_REG) -#define IORD_ALT_AVALON_I2C_RX_DATA(base) IORD(base, ALT_AVALON_I2C_RX_DATA_REG) -#define IOWR_ALT_AVALON_I2C_RX_DATA(base, data) IOWR(base, ALT_AVALON_I2C_RX_DATA_REG, data) -#define ALT_AVALON_I2C_RX_DATA_RXDATA_OFST (0) -#define ALT_AVALON_I2C_RX_DATA_RXDATA_MSK (0xff << ALT_AVALON_I2C_RX_DATA_RXDATA_OFST) - -#define ALT_AVALON_I2C_CTRL_REG 2 -#define IOADDR_ALT_AVALON_I2C_CTRL(base) __IO_CALC_ADDRESS_NATIVE(base, ALT_AVALON_I2C_CTRL_REG) -#define IORD_ALT_AVALON_I2C_CTRL(base) IORD(base, ALT_AVALON_I2C_CTRL_REG) -#define IOWR_ALT_AVALON_I2C_CTRL(base, data) IOWR(base, ALT_AVALON_I2C_CTRL_REG, data) -#define IORMW_ALT_AVALON_I2C_CTRL(base, data, mask) IORMW(base,ALT_AVALON_I2C_CTRL_REG,data,mask) -#define ALT_AVALON_I2C_CTRL_RX_DATA_FIFO_THD_OFST (4) -#define ALT_AVALON_I2C_CTRL_RX_DATA_FIFO_THD_MSK (3 << ALT_AVALON_I2C_CTRL_RX_DATA_FIFO_THD_OFST) -#define ALT_AVALON_I2C_CTRL_TFR_CMD_FIFO_THD_OFST (2) -#define ALT_AVALON_I2C_CTRL_TFR_CMD_FIFO_THD_MSK (3 << ALT_AVALON_I2C_CTRL_TFR_CMD_FIFO_THD_OFST) -#define ALT_AVALON_I2C_CTRL_BUS_SPEED_OFST (1) -#define ALT_AVALON_I2C_CTRL_BUS_SPEED_MSK (1 << ALT_AVALON_I2C_CTRL_BUS_SPEED_OFST) -#define ALT_AVALON_I2C_CTRL_EN_OFST (0) -#define ALT_AVALON_I2C_CTRL_EN_MSK (1 << ALT_AVALON_I2C_CTRL_EN_OFST) - -#define ALT_AVALON_I2C_ISER_REG 3 -#define IOADDR_ALT_AVALON_I2C_ISER(base) __IO_CALC_ADDRESS_NATIVE(base, ALT_AVALON_I2C_ISER_REG) -#define IORD_ALT_AVALON_I2C_ISER(base) IORD(base, ALT_AVALON_I2C_ISER_REG) -#define IOWR_ALT_AVALON_I2C_ISER(base, data) IOWR(base, ALT_AVALON_I2C_ISER_REG, data) -#define IORMW_ALT_AVALON_I2C_ISER(base, data, mask) IORMW(base,ALT_AVALON_I2C_ISER_REG,data,mask) -#define ALT_AVALON_I2C_ISER_RX_OVER_EN_OFST (4) -#define ALT_AVALON_I2C_ISER_RX_OVER_EN_MSK (1 << ALT_AVALON_I2C_ISER_RX_OVER_EN_OFST) -#define ALT_AVALON_I2C_ISER_ARBLOST_DET_EN_OFST (3) -#define ALT_AVALON_I2C_ISER_ARBLOST_DET_EN_MSK (1 << ALT_AVALON_I2C_ISER_ARBLOST_DET_EN_OFST) -#define ALT_AVALON_I2C_ISER_NACK_DET_EN_OFST (2) -#define ALT_AVALON_I2C_ISER_NACK_DET_EN_MSK (1 << ALT_AVALON_I2C_ISER_NACK_DET_EN_OFST) -#define ALT_AVALON_I2C_ISER_RX_READY_EN_OFST (1) -#define ALT_AVALON_I2C_ISER_RX_READY_EN_MSK (1 << ALT_AVALON_I2C_ISER_RX_READY_EN_OFST) -#define ALT_AVALON_I2C_ISER_TX_READY_EN_OFST (0) -#define ALT_AVALON_I2C_ISER_TX_READY_EN_MSK (1 << ALT_AVALON_I2C_ISER_TX_READY_EN_OFST) - -#define ALT_AVALON_I2C_ISR_REG 4 -#define IOADDR_ALT_AVALON_I2C_ISR(base) __IO_CALC_ADDRESS_NATIVE(base, ALT_AVALON_I2C_ISR_REG) -#define IORD_ALT_AVALON_I2C_ISR(base) IORD(base, ALT_AVALON_I2C_ISR_REG) -#define IOWR_ALT_AVALON_I2C_ISR(base, data) IOWR(base, ALT_AVALON_I2C_ISR_REG, data) -#define IORMW_ALT_AVALON_I2C_ISR(base, data, mask) IORMW(base,ALT_AVALON_I2C_ISR_REG,data,mask) -#define ALT_AVALON_I2C_ISR_RX_OVER_OFST (4) -#define ALT_AVALON_I2C_ISR_RX_OVER_MSK (1 << ALT_AVALON_I2C_ISR_RX_OVER_OFST) -#define ALT_AVALON_I2C_ISR_ARBLOST_DET_OFST (3) -#define ALT_AVALON_I2C_ISR_ARBLOST_DET_MSK (1 << ALT_AVALON_I2C_ISR_ARBLOST_DET_OFST) -#define ALT_AVALON_I2C_ISR_NACK_DET_OFST (2) -#define ALT_AVALON_I2C_ISR_NACK_DET_MSK (1 << ALT_AVALON_I2C_ISR_NACK_DET_OFST) -#define ALT_AVALON_I2C_ISR_RX_READY_OFST (1) -#define ALT_AVALON_I2C_ISR_RX_READY_MSK (1 << ALT_AVALON_I2C_ISR_RX_READY_OFST) -#define ALT_AVALON_I2C_ISR_TX_READY_OFST (0) -#define ALT_AVALON_I2C_ISR_TX_READY_MSK (1 << ALT_AVALON_I2C_ISR_TX_READY_OFST) -#define ALT_AVALON_I2C_ISR_ALLINTS_MSK (ALT_AVALON_I2C_ISR_RX_OVER_MSK | ALT_AVALON_I2C_ISR_ARBLOST_DET_MSK | \ - ALT_AVALON_I2C_ISR_NACK_DET_MSK | ALT_AVALON_I2C_ISR_RX_READY_MSK | \ - ALT_AVALON_I2C_ISR_TX_READY_MSK) -#define ALT_AVALON_I2C_ISR_ALL_CLEARABLE_INTS_MSK (ALT_AVALON_I2C_ISR_RX_OVER_MSK | ALT_AVALON_I2C_ISR_ARBLOST_DET_MSK | \ - ALT_AVALON_I2C_ISR_NACK_DET_MSK) - -#define ALT_AVALON_I2C_STATUS_REG 5 -#define IOADDR_ALT_AVALON_I2C_STATUS(base) __IO_CALC_ADDRESS_NATIVE(base, ALT_AVALON_I2C_STATUS_REG) -#define IORD_ALT_AVALON_I2C_STATUS(base) IORD(base, ALT_AVALON_I2C_STATUS_REG) -#define IOWR_ALT_AVALON_I2C_STATUS(base, data) IOWR(base, ALT_AVALON_I2C_STATUS_REG, data) -#define ALT_AVALON_I2C_STATUS_CORE_STATUS_OFST (0) -#define ALT_AVALON_I2C_STATUS_CORE_STATUS_MSK (1 << ALT_AVALON_I2C_STATUS_CORE_STATUS_OFST) - -#define ALT_AVALON_I2C_TFR_CMD_FIFO_LVL_REG 6 -#define IOADDR_ALT_AVALON_I2C_TFR_CMD_FIFO_LVL(base) __IO_CALC_ADDRESS_NATIVE(base, ALT_AVALON_I2C_TFR_CMD_FIFO_LVL_REG) -#define IORD_ALT_AVALON_I2C_TFR_CMD_FIFO_LVL(base) IORD(base, ALT_AVALON_I2C_TFR_CMD_FIFO_LVL_REG) -#define IOWR_ALT_AVALON_I2C_TFR_CMD_FIFO_LVL(base, data) IOWR(base, ALT_AVALON_I2C_TFR_CMD_FIFO_LVL_REG, data) -#define ALT_AVALON_I2C_TFR_CMD_FIFO_LVL_FIFO_DEPTH_OFST (0) -#define ALT_AVALON_I2C_TFR_CMD_FIFO_LVL_FIFO_DEPTH_MSK(cmdfifodepth) ((cmdfifodepth-1) << ALT_AVALON_I2C_TFR_CMD_FIFO_LVL_FIFO_DEPTH_OFST) - -#define ALT_AVALON_I2C_RX_DATA_FIFO_LVL_REG 7 -#define IOADDR_ALT_AVALON_I2C_RX_DATA_FIFO_LVL(base) __IO_CALC_ADDRESS_NATIVE(base, ALT_AVALON_I2C_RX_DATA_FIFO_LVL_REG) -#define IORD_ALT_AVALON_I2C_RX_DATA_FIFO_LVL(base) IORD(base, ALT_AVALON_I2C_RX_DATA_FIFO_LVL_REG) -#define IOWR_ALT_AVALON_I2C_RX_DATA_FIFO_LVL(base, data) IOWR(base, ALT_AVALON_I2C_RX_DATA_FIFO_LVL_REG, data) -#define ALT_AVALON_I2C_RX_DATA_FIFO_LVL_FIFO_DEPTH_OFST (0) -#define ALT_AVALON_I2C_RX_DATA_FIFO_LVL_FIFO_DEPTH_MSK(rxfifodepth) ((rxfifodepth-1) << ALT_AVALON_I2C_TFR_CMD_FIFO_LVL_FIFO_DEPTH_OFST) - -#define ALT_AVALON_I2C_SCL_LOW_REG 8 -#define IOADDR_ALT_AVALON_I2C_SCL_LOW(base) __IO_CALC_ADDRESS_NATIVE(base, ALT_AVALON_I2C_SCL_LOW_REG) -#define IORD_ALT_AVALON_I2C_SCL_LOW(base) IORD(base, ALT_AVALON_I2C_SCL_LOW_REG) -#define IOWR_ALT_AVALON_I2C_SCL_LOW(base, data) IOWR(base, ALT_AVALON_I2C_SCL_LOW_REG, data) -#define ALT_AVALON_I2C_SCL_LOW_COUNT_PERIOD_OFST (0) -#define ALT_AVALON_I2C_SCL_LOW_COUNT_PERIOD_MSK (0xffff << ALT_AVALON_I2C_SCL_LOW_COUNT_PERIOD_OFST) - -#define ALT_AVALON_I2C_SCL_HIGH_REG 9 -#define IOADDR_ALT_AVALON_I2C_SCL_HIGH(base) __IO_CALC_ADDRESS_NATIVE(base, ALT_AVALON_I2C_SCL_HIGH_REG) -#define IORD_ALT_AVALON_I2C_SCL_HIGH(base) IORD(base, ALT_AVALON_I2C_SCL_HIGH_REG) -#define IOWR_ALT_AVALON_I2C_SCL_HIGH(base, data) IOWR(base, ALT_AVALON_I2C_SCL_HIGH_REG, data) -#define ALT_AVALON_I2C_SCL_HIGH_COUNT_PERIOD_OFST (0) -#define ALT_AVALON_I2C_SCL_HIGH_COUNT_PERIOD_MSK (0xffff << ALT_AVALON_I2C_SCL_HIGH_COUNT_PERIOD_OFST) - -#define ALT_AVALON_I2C_SDA_HOLD_REG 0xa -#define IOADDR_ALT_AVALON_I2C_SDA_HOLD(base) __IO_CALC_ADDRESS_NATIVE(base, ALT_AVALON_I2C_SDA_HOLD_REG) -#define IORD_ALT_AVALON_I2C_SDA_HOLD(base) IORD(base, ALT_AVALON_I2C_SDA_HOLD_REG) -#define IOWR_ALT_AVALON_I2C_SDA_HOLD(base, data) IOWR(base, ALT_AVALON_I2C_SDA_HOLD_REG, data) -#define ALT_AVALON_I2C_SDA_HOLD_COUNT_PERIOD_OFST (0) -#define ALT_AVALON_I2C_SDA_HOLD_COUNT_PERIOD_MSK (0xffff << ALT_AVALON_I2C_SDA_HOLD_COUNT_PERIOD_OFST) - -#endif /* __ALT_AVALON_I2C_REGS_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/inc/altera_avalon_jtag_uart.h b/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/inc/altera_avalon_jtag_uart.h deleted file mode 100644 index 32146b914b..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/inc/altera_avalon_jtag_uart.h +++ /dev/null @@ -1,196 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALT_AVALON_JTAG_UART_H__ -#define __ALT_AVALON_JTAG_UART_H__ - -#include - -#include "sys/alt_alarm.h" -#include "sys/alt_warning.h" - -#include "os/alt_sem.h" -#include "os/alt_flag.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * If the user wants all drivers to be small rather than fast then make sure - * this one is marked as needing to be small. - */ -#if defined ALT_USE_SMALL_DRIVERS && !defined ALTERA_AVALON_JTAG_UART_SMALL -#define ALTERA_AVALON_JTAG_UART_SMALL -#endif - -/* - * If the user wants to ignore FIFO full error after timeout - */ -#if defined ALT_JTAG_UART_IGNORE_FIFO_FULL_ERROR && !defined ALTERA_AVALON_JTAG_UART_IGNORE_FIFO_FULL_ERROR -#define ALTERA_AVALON_JTAG_UART_IGNORE_FIFO_FULL_ERROR -#endif - -/* - * Constants that can be overriden. - */ -#ifndef ALTERA_AVALON_JTAG_UART_DEFAULT_TIMEOUT -#define ALTERA_AVALON_JTAG_UART_DEFAULT_TIMEOUT 10 -#endif - -#ifndef ALTERA_AVALON_JTAG_UART_BUF_LEN -#define ALTERA_AVALON_JTAG_UART_BUF_LEN 2048 -#endif - -/* - * ALT_JTAG_UART_READ_RDY and ALT_JTAG_UART_WRITE_RDY are the bitmasks - * that define uC/OS-II event flags that are releated to this device. - * - * ALT_JTAG_UART_READ_RDY indicates that there is read data in the buffer - * ready to be processed. ALT_JTAG_UART_WRITE_RDY indicates that the transmitter is - * ready for more data. - */ -#define ALT_JTAG_UART_READ_RDY 0x1 -#define ALT_JTAG_UART_WRITE_RDY 0x2 -#define ALT_JTAG_UART_TIMEOUT 0x4 - -/* - * State structure definition. Each instance of the driver uses one - * of these structures to hold its associated state. - */ - -typedef struct altera_avalon_jtag_uart_state_s -{ - unsigned int base; - -#ifndef ALTERA_AVALON_JTAG_UART_SMALL - - unsigned int timeout; /* Timeout until host is assumed inactive */ - alt_alarm alarm; - unsigned int irq_enable; - unsigned int host_inactive; - - ALT_SEM (read_lock) - ALT_SEM (write_lock) - ALT_FLAG_GRP (events) - - /* The variables below are volatile because they are modified by the - * interrupt routine. Making them volatile and reading them atomically - * means that we don't need any large critical sections. - */ - volatile unsigned int rx_in; - unsigned int rx_out; - unsigned int tx_in; - volatile unsigned int tx_out; - char rx_buf[ALTERA_AVALON_JTAG_UART_BUF_LEN]; - char tx_buf[ALTERA_AVALON_JTAG_UART_BUF_LEN]; - -#endif /* !ALTERA_AVALON_JTAG_UART_SMALL */ - -} altera_avalon_jtag_uart_state; - -/* - * Macros used by alt_sys_init when the ALT file descriptor facility isn't used. - */ - -#ifdef ALTERA_AVALON_JTAG_UART_SMALL - -#define ALTERA_AVALON_JTAG_UART_STATE_INSTANCE(name, state) \ - altera_avalon_jtag_uart_state state = \ - { \ - name##_BASE, \ - } - -#define ALTERA_AVALON_JTAG_UART_STATE_INIT(name, state) - -#else /* !ALTERA_AVALON_JTAG_UART_SMALL */ - -#define ALTERA_AVALON_JTAG_UART_STATE_INSTANCE(name, state) \ - altera_avalon_jtag_uart_state state = \ - { \ - name##_BASE, \ - ALTERA_AVALON_JTAG_UART_DEFAULT_TIMEOUT, \ - } - -/* - * Externally referenced routines - */ -extern void altera_avalon_jtag_uart_init(altera_avalon_jtag_uart_state* sp, - int irq_controller_id, int irq); - -#define ALTERA_AVALON_JTAG_UART_STATE_INIT(name, state) \ - { \ - if (name##_IRQ == ALT_IRQ_NOT_CONNECTED) \ - { \ - ALT_LINK_ERROR ("Error: Interrupt not connected for " #name ". " \ - "You have selected the interrupt driven version of " \ - "the ALTERA Avalon JTAG UART driver, but the " \ - "interrupt is not connected for this device. You can " \ - "select a polled mode driver by checking the 'small " \ - "driver' option in the HAL configuration window, or " \ - "by using the -DALTERA_AVALON_JTAG_UART_SMALL " \ - "preprocessor flag."); \ - } \ - else \ - altera_avalon_jtag_uart_init(&state, \ - name##_IRQ_INTERRUPT_CONTROLLER_ID, \ - name##_IRQ); \ - } - -#endif /* ALTERA_AVALON_JTAG_UART_SMALL */ - -/* - * Include in case non-direct version of driver required. - */ -#include "altera_avalon_jtag_uart_fd.h" - -/* - * Map alt_sys_init macros to direct or non-direct versions. - */ -#ifdef ALT_USE_DIRECT_DRIVERS - -#define ALTERA_AVALON_JTAG_UART_INSTANCE(name, state) \ - ALTERA_AVALON_JTAG_UART_STATE_INSTANCE(name, state) -#define ALTERA_AVALON_JTAG_UART_INIT(name, state) \ - ALTERA_AVALON_JTAG_UART_STATE_INIT(name, state) - -#else /* !ALT_USE_DIRECT_DRIVERS */ - -#define ALTERA_AVALON_JTAG_UART_INSTANCE(name, dev) \ - ALTERA_AVALON_JTAG_UART_DEV_INSTANCE(name, dev) -#define ALTERA_AVALON_JTAG_UART_INIT(name, dev) \ - ALTERA_AVALON_JTAG_UART_DEV_INIT(name, dev) - -#endif /* ALT_USE_DIRECT_DRIVERS */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_AVALON_JTAG_UART_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/inc/altera_avalon_jtag_uart_fd.h b/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/inc/altera_avalon_jtag_uart_fd.h deleted file mode 100644 index b286cd8cfc..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/inc/altera_avalon_jtag_uart_fd.h +++ /dev/null @@ -1,123 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2007 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALT_AVALON_JTAG_UART_FD_H__ -#define __ALT_AVALON_JTAG_UART_FD_H__ - -#include "sys/alt_dev.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * Externally referenced routines - */ -extern int altera_avalon_jtag_uart_read_fd (alt_fd* fd, char* ptr, int len); -extern int altera_avalon_jtag_uart_write_fd (alt_fd* fd, const char* ptr, - int len); - -/* - * Device structure definition. This is needed by alt_sys_init in order to - * reserve memory for the device instance. - */ - -typedef struct altera_avalon_jtag_uart_dev_s -{ - alt_dev dev; - altera_avalon_jtag_uart_state state; -} altera_avalon_jtag_uart_dev; - -/* - * Macros used by alt_sys_init when the ALT file descriptor facility is used. - */ - -#ifdef ALTERA_AVALON_JTAG_UART_SMALL - -#define ALTERA_AVALON_JTAG_UART_DEV_INSTANCE(name, d) \ - static altera_avalon_jtag_uart_dev d = \ - { \ - { \ - ALT_LLIST_ENTRY, \ - name##_NAME, \ - NULL, /* open */ \ - NULL, /* close */ \ - altera_avalon_jtag_uart_read_fd, \ - altera_avalon_jtag_uart_write_fd, \ - NULL, /* lseek */ \ - NULL, /* fstat */ \ - NULL, /* ioctl */ \ - }, \ - { \ - name##_BASE, \ - } \ - } - -#define ALTERA_AVALON_JTAG_UART_DEV_INIT(name, d) alt_dev_reg (&d.dev) - -#else /* !ALTERA_AVALON_JTAG_UART_SMALL */ - -extern int altera_avalon_jtag_uart_close_fd(alt_fd* fd); -extern int altera_avalon_jtag_uart_ioctl_fd (alt_fd* fd, int req, void* arg); - -#define ALTERA_AVALON_JTAG_UART_DEV_INSTANCE(name, d) \ - static altera_avalon_jtag_uart_dev d = \ - { \ - { \ - ALT_LLIST_ENTRY, \ - name##_NAME, \ - NULL, /* open */ \ - altera_avalon_jtag_uart_close_fd, \ - altera_avalon_jtag_uart_read_fd, \ - altera_avalon_jtag_uart_write_fd, \ - NULL, /* lseek */ \ - NULL, /* fstat */ \ - altera_avalon_jtag_uart_ioctl_fd, \ - }, \ - { \ - name##_BASE, \ - ALTERA_AVALON_JTAG_UART_DEFAULT_TIMEOUT, \ - } \ - } - -#define ALTERA_AVALON_JTAG_UART_DEV_INIT(name, d) \ - { \ - ALTERA_AVALON_JTAG_UART_STATE_INIT(name, d.state); \ - \ - /* make the device available to the system */ \ - alt_dev_reg(&d.dev); \ - } - -#endif /* ALTERA_AVALON_JTAG_UART_SMALL */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_AVALON_JTAG_UART_FD_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/CMakeLists.txt b/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/CMakeLists.txt deleted file mode 100644 index 76117f2042..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -zephyr_sources( - altera_avalon_jtag_uart_fd.c - altera_avalon_jtag_uart_init.c - altera_avalon_jtag_uart_ioctl.c - altera_avalon_jtag_uart_read.c - altera_avalon_jtag_uart_write.c - ) diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_fd.c b/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_fd.c deleted file mode 100644 index 5e74a4b5cc..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_fd.c +++ /dev/null @@ -1,84 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2007 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include "alt_types.h" -#include "sys/alt_dev.h" -#include "altera_avalon_jtag_uart.h" - -extern int altera_avalon_jtag_uart_read(altera_avalon_jtag_uart_state* sp, - char* buffer, int space, int flags); -extern int altera_avalon_jtag_uart_write(altera_avalon_jtag_uart_state* sp, - const char* ptr, int count, int flags); -extern int altera_avalon_jtag_uart_ioctl(altera_avalon_jtag_uart_state* sp, - int req, void* arg); -extern int altera_avalon_jtag_uart_close(altera_avalon_jtag_uart_state* sp, - int flags); - -/* ----------------------------------------------------------------------- */ -/* --------------------- WRAPPERS FOR ALT FD SUPPORT --------------------- */ -/* - * - */ - -int -altera_avalon_jtag_uart_read_fd(alt_fd* fd, char* buffer, int space) -{ - altera_avalon_jtag_uart_dev* dev = (altera_avalon_jtag_uart_dev*) fd->dev; - - return altera_avalon_jtag_uart_read(&dev->state, buffer, space, - fd->fd_flags); -} - -int -altera_avalon_jtag_uart_write_fd(alt_fd* fd, const char* buffer, int space) -{ - altera_avalon_jtag_uart_dev* dev = (altera_avalon_jtag_uart_dev*) fd->dev; - - return altera_avalon_jtag_uart_write(&dev->state, buffer, space, - fd->fd_flags); -} - -#ifndef ALTERA_AVALON_JTAG_UART_SMALL - -int -altera_avalon_jtag_uart_close_fd(alt_fd* fd) -{ - altera_avalon_jtag_uart_dev* dev = (altera_avalon_jtag_uart_dev*) fd->dev; - - return altera_avalon_jtag_uart_close(&dev->state, fd->fd_flags); -} - -int -altera_avalon_jtag_uart_ioctl_fd(alt_fd* fd, int req, void* arg) -{ - altera_avalon_jtag_uart_dev* dev = (altera_avalon_jtag_uart_dev*) fd->dev; - - return altera_avalon_jtag_uart_ioctl(&dev->state, req, arg); -} - -#endif /* ALTERA_AVALON_JTAG_UART_SMALL */ diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_init.c b/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_init.c deleted file mode 100644 index 059b08609e..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_init.c +++ /dev/null @@ -1,254 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2007 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include -#include -#include -#include - -#include - -#include "sys/alt_irq.h" -#include "sys/alt_alarm.h" -#include "sys/ioctl.h" -#include "alt_types.h" - -#include "altera_avalon_jtag_uart_regs.h" -#include "altera_avalon_jtag_uart.h" - -#include "sys/alt_log_printf.h" - -#ifndef ALTERA_AVALON_JTAG_UART_SMALL - -/* ----------------------------------------------------------- */ -/* ------------------------- FAST DRIVER --------------------- */ -/* ----------------------------------------------------------- */ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT -static void altera_avalon_jtag_uart_irq(void* context); -#else -static void altera_avalon_jtag_uart_irq(void* context, alt_u32 id); -#endif -static alt_u32 altera_avalon_jtag_uart_timeout(void* context); - -/* - * Driver initialization code. Register interrupts and start a timer - * which we can use to check whether the host is there. - * Return 1 on sucessful IRQ register and 0 on failure. - */ - -void altera_avalon_jtag_uart_init(altera_avalon_jtag_uart_state* sp, - int irq_controller_id, int irq) -{ - ALT_FLAG_CREATE(&sp->events, 0); - ALT_SEM_CREATE(&sp->read_lock, 1); - ALT_SEM_CREATE(&sp->write_lock, 1); - - /* enable read interrupts at the device */ - sp->irq_enable = ALTERA_AVALON_JTAG_UART_CONTROL_RE_MSK; - - IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(sp->base, sp->irq_enable); - - /* register the interrupt handler */ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT - alt_ic_isr_register(irq_controller_id, irq, altera_avalon_jtag_uart_irq, - sp, NULL); -#else - alt_irq_register(irq, sp, altera_avalon_jtag_uart_irq); -#endif - - /* Register an alarm to go off every second to check for presence of host */ - sp->host_inactive = 0; - - if (alt_alarm_start(&sp->alarm, alt_ticks_per_second(), - &altera_avalon_jtag_uart_timeout, sp) < 0) - { - /* If we can't set the alarm then record "don't know if host present" - * and behave as though the host is present. - */ - sp->timeout = INT_MAX; - } - - /* ALT_LOG - see altera_hal/HAL/inc/sys/alt_log_printf.h */ - ALT_LOG_JTAG_UART_ALARM_REGISTER(sp, sp->base); -} - -/* - * Interrupt routine - */ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT -static void altera_avalon_jtag_uart_irq(void* context) -#else -static void altera_avalon_jtag_uart_irq(void* context, alt_u32 id) -#endif -{ - altera_avalon_jtag_uart_state* sp = (altera_avalon_jtag_uart_state*) context; - unsigned int base = sp->base; - - /* ALT_LOG - see altera_hal/HAL/inc/sys/alt_log_printf.h */ - ALT_LOG_JTAG_UART_ISR_FUNCTION(base, sp); - - for ( ; ; ) - { - unsigned int control = IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base); - - /* Return once nothing more to do */ - if ((control & (ALTERA_AVALON_JTAG_UART_CONTROL_RI_MSK | ALTERA_AVALON_JTAG_UART_CONTROL_WI_MSK)) == 0) - break; - - if (control & ALTERA_AVALON_JTAG_UART_CONTROL_RI_MSK) - { - /* process a read irq. Start by assuming that there is data in the - * receive FIFO (otherwise why would we have been interrupted?) - */ - unsigned int data = 1 << ALTERA_AVALON_JTAG_UART_DATA_RAVAIL_OFST; - - for ( ; ; ) - { - /* Check whether there is space in the buffer. If not then we must not - * read any characters from the buffer as they will be lost. - */ - unsigned int next = (sp->rx_in + 1) % ALTERA_AVALON_JTAG_UART_BUF_LEN; - if (next == sp->rx_out) - break; - - /* Try to remove a character from the FIFO and find out whether there - * are any more characters remaining. - */ - data = IORD_ALTERA_AVALON_JTAG_UART_DATA(base); - - if ((data & ALTERA_AVALON_JTAG_UART_DATA_RVALID_MSK) == 0) - break; - - sp->rx_buf[sp->rx_in] = (data & ALTERA_AVALON_JTAG_UART_DATA_DATA_MSK) >> ALTERA_AVALON_JTAG_UART_DATA_DATA_OFST; - sp->rx_in = (sp->rx_in + 1) % ALTERA_AVALON_JTAG_UART_BUF_LEN; - - /* Post an event to notify jtag_uart_read that a character has been read */ - ALT_FLAG_POST (sp->events, ALT_JTAG_UART_READ_RDY, OS_FLAG_SET); - } - - if (data & ALTERA_AVALON_JTAG_UART_DATA_RAVAIL_MSK) - { - /* If there is still data available here then the buffer is full - * so turn off receive interrupts until some space becomes available. - */ - sp->irq_enable &= ~ALTERA_AVALON_JTAG_UART_CONTROL_RE_MSK; - IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(base, sp->irq_enable); - - /* Dummy read to ensure IRQ is cleared prior to ISR completion */ - IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base); - } - } - - if (control & ALTERA_AVALON_JTAG_UART_CONTROL_WI_MSK) - { - /* process a write irq */ - unsigned int space = (control & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) >> ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_OFST; - - while (space > 0 && sp->tx_out != sp->tx_in) - { - IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, sp->tx_buf[sp->tx_out]); - - sp->tx_out = (sp->tx_out + 1) % ALTERA_AVALON_JTAG_UART_BUF_LEN; - - /* Post an event to notify jtag_uart_write that a character has been written */ - ALT_FLAG_POST (sp->events, ALT_JTAG_UART_WRITE_RDY, OS_FLAG_SET); - - space--; - } - - if (space > 0) - { - /* If we don't have any more data available then turn off the TX interrupt */ - sp->irq_enable &= ~ALTERA_AVALON_JTAG_UART_CONTROL_WE_MSK; - IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(sp->base, sp->irq_enable); - - /* Dummy read to ensure IRQ is cleared prior to ISR completion */ - IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base); - } - } - } -} - -/* - * Timeout routine is called every second - */ - -static alt_u32 -altera_avalon_jtag_uart_timeout(void* context) -{ - altera_avalon_jtag_uart_state* sp = (altera_avalon_jtag_uart_state *) context; - - unsigned int control = IORD_ALTERA_AVALON_JTAG_UART_CONTROL(sp->base); - - if (control & ALTERA_AVALON_JTAG_UART_CONTROL_AC_MSK) - { - IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(sp->base, sp->irq_enable | ALTERA_AVALON_JTAG_UART_CONTROL_AC_MSK); - sp->host_inactive = 0; - } - else if (sp->host_inactive < INT_MAX - 2) { - sp->host_inactive++; - - if (sp->host_inactive >= sp->timeout) { - /* Post an event to indicate host is inactive (for jtag_uart_read */ - ALT_FLAG_POST (sp->events, ALT_JTAG_UART_TIMEOUT, OS_FLAG_SET); - } - } - - return alt_ticks_per_second(); -} - -/* - * The close() routine is implemented to drain the JTAG UART transmit buffer - * when not in "small" mode. This routine will wait for transimt data to be - * emptied unless a timeout from host-activity occurs. If the driver flags - * have been set to non-blocking mode, this routine will exit immediately if - * any data remains. This routine should be called indirectly (i.e. though - * the C library close() routine) so that the file descriptor associated - * with the relevant stream (i.e. stdout) can be closed as well. This routine - * does not manage file descriptors. - * - * The close routine is not implemented for the small driver; instead it will - * map to null. This is because the small driver simply waits while characters - * are transmitted; there is no interrupt-serviced buffer to empty - */ -int altera_avalon_jtag_uart_close(altera_avalon_jtag_uart_state* sp, int flags) -{ - /* - * Wait for all transmit data to be emptied by the JTAG UART ISR, or - * for a host-inactivity timeout, in which case transmit data will be lost - */ - while ( (sp->tx_out != sp->tx_in) && (sp->host_inactive < sp->timeout) ) { - if (flags & O_NONBLOCK) { - return -EWOULDBLOCK; - } - } - - return 0; -} - -#endif /* !ALTERA_AVALON_JTAG_UART_SMALL */ diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_ioctl.c b/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_ioctl.c deleted file mode 100644 index 5d0cb4bcbd..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_ioctl.c +++ /dev/null @@ -1,84 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include -#include -#include -#include - -#include - -#include "sys/ioctl.h" -#include "alt_types.h" - -#include "altera_avalon_jtag_uart_regs.h" -#include "altera_avalon_jtag_uart.h" - -#include "sys/alt_log_printf.h" - -#ifndef ALTERA_AVALON_JTAG_UART_SMALL - -/* ----------------------------------------------------------- */ -/* ------------------------- FAST DRIVER --------------------- */ -/* ----------------------------------------------------------- */ - -int -altera_avalon_jtag_uart_ioctl(altera_avalon_jtag_uart_state* sp, int req, - void* arg) -{ - int rc = -ENOTTY; - - switch (req) - { - case TIOCSTIMEOUT: - /* Set the time to wait until assuming host is not connected */ - if (sp->timeout != INT_MAX) - { - int timeout = *((int *)arg); - sp->timeout = (timeout >= 2 && timeout < INT_MAX) ? timeout : INT_MAX - 1; - rc = 0; - } - break; - - case TIOCGCONNECTED: - /* Find out whether host is connected */ - if (sp->timeout != INT_MAX) - { - *((int *)arg) = (sp->host_inactive < sp->timeout) ? 1 : 0; - rc = 0; - } - break; - - default: - break; - } - - return rc; -} - -#endif /* !ALTERA_AVALON_JTAG_UART_SMALL */ diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_read.c b/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_read.c deleted file mode 100644 index b2769514d7..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_read.c +++ /dev/null @@ -1,203 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include -#include -#include -#include - -#include - -#include "sys/alt_irq.h" -#include "sys/alt_alarm.h" -#include "sys/ioctl.h" -#include "alt_types.h" - -#include "altera_avalon_jtag_uart_regs.h" -#include "altera_avalon_jtag_uart.h" - -#include "sys/alt_log_printf.h" - -#ifdef __ucosii__ -#include "includes.h" -#endif /* __ucosii__ */ - -#ifdef ALTERA_AVALON_JTAG_UART_SMALL - -/* ----------------------------------------------------------- */ -/* ----------------------- SMALL DRIVER ---------------------- */ -/* ----------------------------------------------------------- */ - -/* Read routine. The small version blocks until it has at least one byte - * available, it then returns as much as is immediately available without - * waiting any more. It's performance will be very poor without - * interrupts. - */ - -int -altera_avalon_jtag_uart_read(altera_avalon_jtag_uart_state* sp, - char* buffer, int space, int flags) -{ - unsigned int base = sp->base; - - char * ptr = buffer; - char * end = buffer + space; - - while (ptr < end) - { - unsigned int data = IORD_ALTERA_AVALON_JTAG_UART_DATA(base); - - if (data & ALTERA_AVALON_JTAG_UART_DATA_RVALID_MSK) - *ptr++ = (data & ALTERA_AVALON_JTAG_UART_DATA_DATA_MSK) >> ALTERA_AVALON_JTAG_UART_DATA_DATA_OFST; - else if (ptr != buffer) - break; - else if(flags & O_NONBLOCK) - break; - - } - - if (ptr != buffer) - return ptr - buffer; - else if (flags & O_NONBLOCK) - return -EWOULDBLOCK; - else - return -EIO; -} - -#else /* !ALTERA_AVALON_JTAG_UART_SMALL */ - -/* ----------------------------------------------------------- */ -/* ----------------------- FAST DRIVER ----------------------- */ -/* ----------------------------------------------------------- */ - -int -altera_avalon_jtag_uart_read(altera_avalon_jtag_uart_state* sp, - char * buffer, int space, int flags) -{ - char * ptr = buffer; - - alt_irq_context context; - unsigned int n; - - /* - * When running in a multi threaded environment, obtain the "read_lock" - * semaphore. This ensures that reading from the device is thread-safe. - */ - ALT_SEM_PEND (sp->read_lock, 0); - - while (space > 0) - { - unsigned int in, out; - - /* Read as much data as possible */ - do - { - in = sp->rx_in; - out = sp->rx_out; - - if (in >= out) - n = in - out; - else - n = ALTERA_AVALON_JTAG_UART_BUF_LEN - out; - - if (n == 0) - break; /* No more data available */ - - if (n > space) - n = space; - - memcpy(ptr, sp->rx_buf + out, n); - ptr += n; - space -= n; - - sp->rx_out = (out + n) % ALTERA_AVALON_JTAG_UART_BUF_LEN; - } - while (space > 0); - - /* If we read any data then return it */ - if (ptr != buffer) - break; - - /* If in non-blocking mode then return error */ - if (flags & O_NONBLOCK) - break; - -#ifdef __ucosii__ - /* OS Present: Pend on a flag if the OS is running, otherwise spin */ - if(OSRunning == OS_TRUE) { - /* - * When running in a multi-threaded mode, we pend on the read event - * flag set and timeout event flag set in the isr. This avoids wasting CPU - * cycles waiting in this thread, when we could be doing something more - * profitable elsewhere. - */ - ALT_FLAG_PEND (sp->events, - ALT_JTAG_UART_READ_RDY | ALT_JTAG_UART_TIMEOUT, - OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME, - 0); - } - else { - /* Spin until more data arrives or until host disconnects */ - while (in == sp->rx_in && sp->host_inactive < sp->timeout) - ; - } -#else - /* No OS: Always spin */ - while (in == sp->rx_in && sp->host_inactive < sp->timeout) - ; -#endif /* __ucosii__ */ - - if (in == sp->rx_in) - break; - } - - /* - * Now that access to the circular buffer is complete, release the read - * semaphore so that other threads can access the buffer. - */ - - ALT_SEM_POST (sp->read_lock); - - if (ptr != buffer) - { - /* If we read any data then there is space in the buffer so enable interrupts */ - context = alt_irq_disable_all(); - sp->irq_enable |= ALTERA_AVALON_JTAG_UART_CONTROL_RE_MSK; - IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(sp->base, sp->irq_enable); - alt_irq_enable_all(context); - } - - if (ptr != buffer) - return ptr - buffer; - else if (flags & O_NONBLOCK) - return -EWOULDBLOCK; - else - return -EIO; -} - -#endif /* ALTERA_AVALON_JTAG_UART_SMALL */ diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_write.c b/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_write.c deleted file mode 100644 index b6d04094d1..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/HAL/src/altera_avalon_jtag_uart_write.c +++ /dev/null @@ -1,215 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include -#include -#include -#include - -#include - -#include "sys/alt_irq.h" -#include "sys/alt_alarm.h" -#include "sys/ioctl.h" -#include "alt_types.h" - -#include "altera_avalon_jtag_uart_regs.h" -#include "altera_avalon_jtag_uart.h" - -#include "sys/alt_log_printf.h" - -#ifdef __ucosii__ -#include "includes.h" -#endif /* __ucosii__ */ - -#ifdef ALTERA_AVALON_JTAG_UART_SMALL - -/* ----------------------------------------------------------- */ -/* ------------------------ SMALL DRIVER --------------------- */ -/* ----------------------------------------------------------- */ - -/* Write routine. The small version blocks when there is no space to write - * into, so it's performance will be very bad if you are writing more than - * one FIFOs worth of data. But you said you didn't want to use interrupts :-) - */ - -int altera_avalon_jtag_uart_write(altera_avalon_jtag_uart_state* sp, - const char * ptr, int count, int flags) -{ - unsigned int base = sp->base; - - const char * end = ptr + count; - - while (ptr < end) - if ((IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base) & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) != 0) - IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, *ptr++); - - return count; -} - -#else /* !ALTERA_AVALON_JTAG_UART_SMALL */ - -/* ----------------------------------------------------------- */ -/* ------------------------- FAST DRIVER --------------------- */ -/* ----------------------------------------------------------- */ - -int -altera_avalon_jtag_uart_write(altera_avalon_jtag_uart_state* sp, - const char * ptr, int count, int flags) -{ - /* Remove warning at optimisation level 03 by seting out to 0 */ - unsigned int in, out=0; - unsigned int n; - alt_irq_context context; - - const char * start = ptr; - - /* - * When running in a multi threaded environment, obtain the "write_lock" - * semaphore. This ensures that writing to the device is thread-safe. - */ - ALT_SEM_PEND (sp->write_lock, 0); - - do - { - /* Copy as much as we can into the transmit buffer */ - while (count > 0) - { - /* We need a stable value of the out pointer to calculate the space available */ - in = sp->tx_in; - out = sp->tx_out; - - if (in < out) - n = out - 1 - in; - else if (out > 0) - n = ALTERA_AVALON_JTAG_UART_BUF_LEN - in; - else - n = ALTERA_AVALON_JTAG_UART_BUF_LEN - 1 - in; - - if (n == 0) - break; - - if (n > count) - n = count; - - memcpy(sp->tx_buf + in, ptr, n); - ptr += n; - count -= n; - - sp->tx_in = (in + n) % ALTERA_AVALON_JTAG_UART_BUF_LEN; - } - - /* - * If interrupts are disabled then we could transmit here, we only need - * to enable interrupts if there is no space left in the FIFO - * - * For now kick the interrupt routine every time to make it transmit - * the data - */ - context = alt_irq_disable_all(); - sp->irq_enable |= ALTERA_AVALON_JTAG_UART_CONTROL_WE_MSK; - IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(sp->base, sp->irq_enable); - alt_irq_enable_all(context); - - /* - * If there is any data left then either return now or block until - * some has been sent - */ - /* consider: test whether there is anything there while doing this and delay for at most 2s. */ - if (count > 0) - { - if (flags & O_NONBLOCK) - break; - -#ifdef __ucosii__ - /* OS Present: Pend on a flag if the OS is running, otherwise spin */ - if(OSRunning == OS_TRUE) { - /* - * When running in a multi-threaded mode, we pend on the write event - * flag set or the timeout flag in the isr. This avoids wasting CPU - * cycles waiting in this thread, when we could be doing something - * more profitable elsewhere. - */ -#ifdef ALTERA_AVALON_JTAG_UART_IGNORE_FIFO_FULL_ERROR - if(!sp->host_inactive) -#endif - ALT_FLAG_PEND (sp->events, - ALT_JTAG_UART_WRITE_RDY | ALT_JTAG_UART_TIMEOUT, - OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME, - 0); - } - else { - /* - * OS not running: Wait for data to be removed from buffer. - * Once the interrupt routine has removed some data then we - * will be able to insert some more. - */ - while (out == sp->tx_out && sp->host_inactive < sp->timeout) - ; - } -#else - /* - * No OS present: Always wait for data to be removed from buffer. Once - * the interrupt routine has removed some data then we will be able to - * insert some more. - */ - while (out == sp->tx_out && sp->host_inactive < sp->timeout) - ; -#endif /* __ucosii__ */ - - if (sp->host_inactive) - break; - } - } - while (count > 0); - - /* - * Now that access to the circular buffer is complete, release the write - * semaphore so that other threads can access the buffer. - */ - ALT_SEM_POST (sp->write_lock); - - if (ptr != start) - return ptr - start; - else if (flags & O_NONBLOCK) - return -EWOULDBLOCK; -#ifdef ALTERA_AVALON_JTAG_UART_IGNORE_FIFO_FULL_ERROR - else if (sp->host_inactive >= sp->timeout) { - /* - * Reset the software FIFO, hardware FIFO could not be reset. - * Just throw away characters without reporting error. - */ - sp->tx_out = sp->tx_in = 0; - return ptr - start + count; - } -#endif - else - return -EIO; /* Host not connected */ -} - -#endif /* ALTERA_AVALON_JTAG_UART_SMALL */ diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/LWHAL/inc/altera_avalon_jtag_uart_lwhal.h b/ext/hal/altera/drivers/altera_avalon_jtag_uart/LWHAL/inc/altera_avalon_jtag_uart_lwhal.h deleted file mode 100644 index e70a6b5828..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/LWHAL/inc/altera_avalon_jtag_uart_lwhal.h +++ /dev/null @@ -1,34 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2010 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALT_AVALON_JTAG_UART_LWHAL_H__ -#define __ALT_AVALON_JTAG_UART_LWHAL_H__ - -extern void altera_avalon_jtag_uart_lwhal_putchar(void *base, int character); - -#endif /* __ALT_AVALON_JTAG_UART_LWHAL_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/LWHAL/src/CMakeLists.txt b/ext/hal/altera/drivers/altera_avalon_jtag_uart/LWHAL/src/CMakeLists.txt deleted file mode 100644 index 07038197cf..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/LWHAL/src/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -zephyr_sources(altera_avalon_jtag_uart_lwhal_putchar.c) diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/LWHAL/src/altera_avalon_jtag_uart_lwhal_putchar.c b/ext/hal/altera/drivers/altera_avalon_jtag_uart/LWHAL/src/altera_avalon_jtag_uart_lwhal_putchar.c deleted file mode 100644 index f4c7891034..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/LWHAL/src/altera_avalon_jtag_uart_lwhal_putchar.c +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2010 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include "alt_types.h" -#include "altera_avalon_jtag_uart_regs.h" -#include "altera_avalon_jtag_uart_lwhal.h" - - -/********************************************************************/ - -/** @Function Description: Writes a single character to the JTAG UART. - * @API Type: External - * @param base JTAG UART base address - * @param character Character to be written - * @return None - * - */ -void altera_avalon_jtag_uart_lwhal_putchar(void *base, int character) -{ - do { - if ((IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base) & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) != 0) - { - IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, (character & 0xff)); - return; - } - }while(1); - - return; -} diff --git a/ext/hal/altera/drivers/altera_avalon_jtag_uart/inc/altera_avalon_jtag_uart_regs.h b/ext/hal/altera/drivers/altera_avalon_jtag_uart/inc/altera_avalon_jtag_uart_regs.h deleted file mode 100644 index 61351476f4..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_jtag_uart/inc/altera_avalon_jtag_uart_regs.h +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALTERA_AVALON_JTAG_UART_REGS_H__ -#define __ALTERA_AVALON_JTAG_UART_REGS_H__ - -#include - -#define ALTERA_AVALON_JTAG_UART_DATA_REG 0 -#define IOADDR_ALTERA_AVALON_JTAG_UART_DATA(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_JTAG_UART_DATA_REG) -#define IORD_ALTERA_AVALON_JTAG_UART_DATA(base) \ - IORD(base, ALTERA_AVALON_JTAG_UART_DATA_REG) -#define IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, data) \ - IOWR(base, ALTERA_AVALON_JTAG_UART_DATA_REG, data) - -#define ALTERA_AVALON_JTAG_UART_DATA_DATA_MSK (0x000000FF) -#define ALTERA_AVALON_JTAG_UART_DATA_DATA_OFST (0) -#define ALTERA_AVALON_JTAG_UART_DATA_RVALID_MSK (0x00008000) -#define ALTERA_AVALON_JTAG_UART_DATA_RVALID_OFST (15) -#define ALTERA_AVALON_JTAG_UART_DATA_RAVAIL_MSK (0xFFFF0000) -#define ALTERA_AVALON_JTAG_UART_DATA_RAVAIL_OFST (16) - - -#define ALTERA_AVALON_JTAG_UART_CONTROL_REG 1 -#define IOADDR_ALTERA_AVALON_JTAG_UART_CONTROL(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_JTAG_UART_CONTROL_REG) -#define IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base) \ - IORD(base, ALTERA_AVALON_JTAG_UART_CONTROL_REG) -#define IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(base, data) \ - IOWR(base, ALTERA_AVALON_JTAG_UART_CONTROL_REG, data) - -#define ALTERA_AVALON_JTAG_UART_CONTROL_RE_MSK (0x00000001) -#define ALTERA_AVALON_JTAG_UART_CONTROL_RE_OFST (0) -#define ALTERA_AVALON_JTAG_UART_CONTROL_WE_MSK (0x00000002) -#define ALTERA_AVALON_JTAG_UART_CONTROL_WE_OFST (1) -#define ALTERA_AVALON_JTAG_UART_CONTROL_RI_MSK (0x00000100) -#define ALTERA_AVALON_JTAG_UART_CONTROL_RI_OFST (8) -#define ALTERA_AVALON_JTAG_UART_CONTROL_WI_MSK (0x00000200) -#define ALTERA_AVALON_JTAG_UART_CONTROL_WI_OFST (9) -#define ALTERA_AVALON_JTAG_UART_CONTROL_AC_MSK (0x00000400) -#define ALTERA_AVALON_JTAG_UART_CONTROL_AC_OFST (10) -#define ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK (0xFFFF0000) -#define ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_OFST (16) - -#endif /* __ALTERA_AVALON_JTAG_UART_REGS_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_pio/inc/altera_avalon_pio_regs.h b/ext/hal/altera/drivers/altera_avalon_pio/inc/altera_avalon_pio_regs.h deleted file mode 100644 index d86a5152f7..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_pio/inc/altera_avalon_pio_regs.h +++ /dev/null @@ -1,65 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALTERA_AVALON_PIO_REGS_H__ -#define __ALTERA_AVALON_PIO_REGS_H__ - -#include - -#define IOADDR_ALTERA_AVALON_PIO_DATA(base) __IO_CALC_ADDRESS_NATIVE(base, 0) -#define IORD_ALTERA_AVALON_PIO_DATA(base) IORD(base, 0) -#define IOWR_ALTERA_AVALON_PIO_DATA(base, data) IOWR(base, 0, data) - -#define IOADDR_ALTERA_AVALON_PIO_DIRECTION(base) __IO_CALC_ADDRESS_NATIVE(base, 1) -#define IORD_ALTERA_AVALON_PIO_DIRECTION(base) IORD(base, 1) -#define IOWR_ALTERA_AVALON_PIO_DIRECTION(base, data) IOWR(base, 1, data) - -#define IOADDR_ALTERA_AVALON_PIO_IRQ_MASK(base) __IO_CALC_ADDRESS_NATIVE(base, 2) -#define IORD_ALTERA_AVALON_PIO_IRQ_MASK(base) IORD(base, 2) -#define IOWR_ALTERA_AVALON_PIO_IRQ_MASK(base, data) IOWR(base, 2, data) - -#define IOADDR_ALTERA_AVALON_PIO_EDGE_CAP(base) __IO_CALC_ADDRESS_NATIVE(base, 3) -#define IORD_ALTERA_AVALON_PIO_EDGE_CAP(base) IORD(base, 3) -#define IOWR_ALTERA_AVALON_PIO_EDGE_CAP(base, data) IOWR(base, 3, data) - - -#define IOADDR_ALTERA_AVALON_PIO_SET_BIT(base) __IO_CALC_ADDRESS_NATIVE(base, 4) -#define IORD_ALTERA_AVALON_PIO_SET_BITS(base) IORD(base, 4) -#define IOWR_ALTERA_AVALON_PIO_SET_BITS(base, data) IOWR(base, 4, data) - -#define IOADDR_ALTERA_AVALON_PIO_CLEAR_BITS(base) __IO_CALC_ADDRESS_NATIVE(base, 5) -#define IORD_ALTERA_AVALON_PIO_CLEAR_BITS(base) IORD(base, 5) -#define IOWR_ALTERA_AVALON_PIO_CLEAR_BITS(base, data) IOWR(base, 5, data) - - - -/* Defintions for direction-register operation with bi-directional PIOs */ -#define ALTERA_AVALON_PIO_DIRECTION_INPUT 0 -#define ALTERA_AVALON_PIO_DIRECTION_OUTPUT 1 - -#endif /* __ALTERA_AVALON_PIO_REGS_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/inc/altera_avalon_sgdma.h b/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/inc/altera_avalon_sgdma.h deleted file mode 100644 index 0c6e127375..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/inc/altera_avalon_sgdma.h +++ /dev/null @@ -1,230 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2011 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALTERA_AVALON_SGDMA_H__ -#define __ALTERA_AVALON_SGDMA_H__ - -#include -#include - -#include "sys/alt_dev.h" -#include "alt_types.h" -#include "altera_avalon_sgdma_descriptor.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * The function alt_find_dev() is used to search the device list "list" to - * locate a device named "name". If a match is found, then a pointer to the - * device is returned, otherwise NULL is returned. - */ -extern alt_dev* alt_find_dev (const char* name, alt_llist* list); - -/* Callback routine type definition */ -typedef void (*alt_avalon_sgdma_callback)(void *context); - -/* SGDMA Device Structure */ -typedef struct alt_sgdma_dev -{ - alt_llist llist; // Device linked-list entry - const char *name; // Name of SGDMA in SOPC System - void *base; // Base address of SGDMA - alt_u32 *descriptor_base; // reserved - alt_u32 next_index; // reserved - alt_u32 num_descriptors; // reserved - alt_sgdma_descriptor *current_descriptor; // reserved - alt_sgdma_descriptor *next_descriptor; // reserved - alt_avalon_sgdma_callback callback; // Callback routine pointer - void *callback_context; // Callback context pointer - alt_u32 chain_control; // Value OR'd into control reg -} alt_sgdma_dev; - - -/******************************************************************************* - * Public API - ******************************************************************************/ - -/* API for "application managed" operation */ -int alt_avalon_sgdma_do_async_transfer( - alt_sgdma_dev *dev, - alt_sgdma_descriptor *desc); - -alt_u8 alt_avalon_sgdma_do_sync_transfer( - alt_sgdma_dev *dev, - alt_sgdma_descriptor *desc); - -void alt_avalon_sgdma_construct_mem_to_mem_desc( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u32 *write_addr, - alt_u16 length, - int read_fixed, - int write_fixed); - -void alt_avalon_sgdma_construct_mem_to_mem_desc_burst( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u32 *write_addr, - alt_u16 length, - int read_fixed, - int write_fixed, - int read_burst, - int write_burst); - -void alt_avalon_sgdma_construct_stream_to_mem_desc( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *write_addr, - alt_u16 length_or_eop, - int write_fixed); - -void alt_avalon_sgdma_construct_stream_to_mem_desc_burst( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *write_addr, - alt_u16 length_or_eop, - int write_fixed, - int write_burst); - - void alt_avalon_sgdma_construct_mem_to_stream_desc( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u16 length, - int read_fixed, - int generate_sop, - int generate_eop, - alt_u8 atlantic_channel); - - void alt_avalon_sgdma_construct_mem_to_stream_desc_burst( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u16 length, - int read_fixed, - int generate_sop, - int generate_eop, - int read_burst, - alt_u8 atlantic_channel); - -void alt_avalon_sgdma_register_callback( - alt_sgdma_dev *dev, - alt_avalon_sgdma_callback callback, - alt_u32 chain_control, - void *context); - -void alt_avalon_sgdma_start(alt_sgdma_dev *dev); - -void alt_avalon_sgdma_stop(alt_sgdma_dev *dev); - -int alt_avalon_sgdma_check_descriptor_status(alt_sgdma_descriptor *desc); - -alt_sgdma_dev* alt_avalon_sgdma_open (const char* name); - -void alt_avalon_sgdma_enable_desc_poll(alt_sgdma_dev *dev, alt_u32 frequency); - -void alt_avalon_sgdma_disable_desc_poll(alt_sgdma_dev *dev); - -/* Private API */ -void alt_avalon_sgdma_construct_descriptor( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u32 *write_addr, - alt_u16 length_or_eop, - int generate_eop, - int read_fixed, - int write_fixed_or_sop, - alt_u8 atlantic_channel); - -/* Private API */ -void alt_avalon_sgdma_construct_descriptor_burst( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u32 *write_addr, - alt_u16 length_or_eop, - int generate_eop, - int read_fixed, - int write_fixed_or_sop, - int read_burst, - int write_burst, - alt_u8 atlantic_channel); - -void alt_avalon_sgdma_init (alt_sgdma_dev *dev, alt_u32 ic_id, alt_u32 irq); - -/* HAL initialization macros */ - -/* - * ALTERA_AVALON_SGDMA_INSTANCE is the macro used by alt_sys_init() to - * allocate any per device memory that may be required. - */ -#define ALTERA_AVALON_SGDMA_INSTANCE(name, dev) \ -static alt_sgdma_dev dev = \ -{ \ - ALT_LLIST_ENTRY, \ - name##_NAME, \ - ((void *)(name##_BASE)), \ - ((alt_u32 *) 0x0), \ - ((alt_u32) 0x0), \ - ((alt_u32) 0x0), \ - ((alt_sgdma_descriptor *) 0x0), \ - ((alt_sgdma_descriptor *) 0x0), \ - ((void *) 0x0), \ - ((void *) 0x0), \ - ((alt_u16) 0x0) \ -}; - -/* - * The macro ALTERA_AVALON_SGDMA_INIT is called by the auto-generated function - * alt_sys_init() to initialize a given device instance. - */ -#define ALTERA_AVALON_SGDMA_INIT(name, dev) \ - if (name##_IRQ == ALT_IRQ_NOT_CONNECTED) \ - { \ - ALT_LINK_ERROR ("Error: Interrupt not connected for " #dev ". " \ - "The Altera Avalon Scatter-Gather DMA driver requires " \ - "that an interrupt is connected. Please select an IRQ " \ - "for this device in SOPC builder."); \ - } \ - else \ - { \ - alt_avalon_sgdma_init(&dev, name##_IRQ_INTERRUPT_CONTROLLER_ID, \ - name##_IRQ); \ - } - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALTERA_AVALON_SGDMA_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/inc/altera_avalon_sgdma_descriptor.h b/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/inc/altera_avalon_sgdma_descriptor.h deleted file mode 100644 index 5f8de09204..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/inc/altera_avalon_sgdma_descriptor.h +++ /dev/null @@ -1,115 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ -#ifndef __ALTERA_AVALON_SGDMA_DESCRIPTOR_H__ -#define __ALTERA_AVALON_SGDMA_DESCRIPTOR_H__ - -#include "alt_types.h" - -/* Each Scatter-gather DMA buffer descriptor spans 0x20 of memory */ -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_SIZE (0x20) - - -/* - * Descriptor control bit masks & offsets - * - * Note: The control byte physically occupies bits [31:24] in memory. - * The following bit-offsets are expressed relative to the LSB of - * the control register bitfield. - */ -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_GENERATE_EOP_MSK (0x1) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_GENERATE_EOP_OFST (0) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_READ_FIXED_ADDRESS_MSK (0x2) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_READ_FIXED_ADDRESS_OFST (1) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_WRITE_FIXED_ADDRESS_MSK (0x4) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_WRITE_FIXED_ADDRESS_OFST (2) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_ATLANTIC_CHANNEL_MSK (0x8) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_ATLANTIC_CHANNEL_OFST (3) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK (0x80) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_OFST (7) - -/* - * Descriptor status bit masks & offsets - * - * Note: The status byte physically occupies bits [23:16] in memory. - * The following bit-offsets are expressed relative to the LSB of - * the status register bitfield. - */ -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_CRC_MSK (0x1) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_CRC_OFST (0) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_PARITY_MSK (0x2) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_PARITY_OFST (1) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_OVERFLOW_MSK (0x4) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_OVERFLOW_OFST (2) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_SYNC_MSK (0x8) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_SYNC_OFST (3) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_UEOP_MSK (0x10) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_UEOP_OFST (4) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_MEOP_MSK (0x20) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_MEOP_OFST (5) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_MSOP_MSK (0x40) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_MSOP_OFST (6) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_TERMINATED_BY_EOP_MSK (0x80) -#define ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_TERMINATED_BY_EOP_OFST (7) - -/* - * To ensure that a descriptor is created without spaces - * between the struct members, we call upon GCC's ability - * to pack to a byte-aligned boundary. - */ -#define alt_avalon_sgdma_packed __attribute__ ((packed,aligned(1))) - -/* - * Buffer Descriptor data structure - * - * The SGDMA controller buffer descriptor allocates - * 64 bits for each address. To support ANSI C, the - * struct implementing a descriptor places 32-bits - * of padding directly above each address; each pad must - * be cleared when initializing a descriptor. - */ -typedef struct { - alt_u32 *read_addr; - alt_u32 read_addr_pad; - - alt_u32 *write_addr; - alt_u32 write_addr_pad; - - alt_u32 *next; - alt_u32 next_pad; - - alt_u16 bytes_to_transfer; - alt_u8 read_burst; - alt_u8 write_burst; - - alt_u16 actual_bytes_transferred; - alt_u8 status; - alt_u8 control; - -} alt_avalon_sgdma_packed alt_sgdma_descriptor; - -#endif /* __ALTERA_AVALON_SGDMA_DESCRIPTOR_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/src/CMakeLists.txt b/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/src/CMakeLists.txt deleted file mode 100644 index a7e77576c7..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/src/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -zephyr_sources(altera_avalon_sgdma.c) diff --git a/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/src/altera_avalon_sgdma.c b/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/src/altera_avalon_sgdma.c deleted file mode 100644 index 99bd0111f1..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_sgdma/HAL/src/altera_avalon_sgdma.c +++ /dev/null @@ -1,798 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2011 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/* - * Altera HAL driver suitable for Nios II to drive the altera_avalon_sgdma - * controller. - * - * The routines contained in this file are intended for developers who - * wish to manage descriptors in their own application code. No facility - * for automatic descriptor buffer management is provided. Use this API if - * you want to: - * - Construct your own descriptors or descriptor chains in your - * application code - * - Use the SGDMA controller for simple "one off" transfers or for - * chains of transfers that you setup manually. - * - * Author: JRK - */ - -#include "io.h" -#include "sys/alt_irq.h" -#include "sys/alt_errno.h" -#include "sys/alt_cache.h" - -#include "altera_avalon_sgdma.h" -#include "altera_avalon_sgdma_regs.h" - -/* The list of registered SGDMA components */ -ALT_LLIST_HEAD(alt_sgdma_list); - -/* - * alt_avalon_sgdma_do_async_transfer - * - * Set up and commence a non-blocking transfer of one of more - * descriptors (or descriptor chain). - * - * If the SGDMA controller is busy at the time of this call, the - * routine will immediately reutrn -EBUSY; the application can then - * decide how to proceed without being blocked. - * - * If a callback routine has been previously registered with this - * particular SGDMA controller, the transfer will be set up to - * issue an interrupt on error, EOP, or chain completion. Otherwise, - * no interrupt is registered, and it is the responsibility of the - * aplication developer to check for and suitably handle errors - * and completion. - * - * Arguments: - * - *dev: Pointer to SGDMA device (instance) struct. - * - *desc: Pointer to single (ready to run) descriptor. The descriptor - * is expected to have its "next" descriptor field initialized either - * to a non-ready descriptor, or to the next in a chain. - * - * Returns: - * - 0 for success, or various errors defined in - */ -int alt_avalon_sgdma_do_async_transfer( - alt_sgdma_dev *dev, - alt_sgdma_descriptor *desc) -{ - alt_u32 control; - - /* Return with error immediately if controller is busy */ - if( (IORD_ALTERA_AVALON_SGDMA_STATUS(dev->base) & - ALTERA_AVALON_SGDMA_STATUS_BUSY_MSK) ) { - return -EBUSY; - } - - /* Clear Run */ - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, - (IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base) & - ~ALTERA_AVALON_SGDMA_CONTROL_RUN_MSK) ); - - /* - * Clear any (previous) status register information - * that might occlude our error checking later. - */ - IOWR_ALTERA_AVALON_SGDMA_STATUS(dev->base, 0xFF); - - /* Point the controller at the descriptor */ - IOWR_ALTERA_AVALON_SGDMA_NEXT_DESC_POINTER(dev->base, (alt_u32) desc); - - /* - * If a callback routine has been previously registered which will be - * called from the SGDMA ISR. Set up controller to: - * - Run - * - Stop on an error with any particular descriptor - * - Include any control register bits registered with along with - * the callback routine (effectively, interrupts are controlled - * via the control bits set during callback-register time). - */ - if(dev->callback) { - control = IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base); - - control |= (dev->chain_control | - ALTERA_AVALON_SGDMA_CONTROL_RUN_MSK | - ALTERA_AVALON_SGDMA_CONTROL_STOP_DMA_ER_MSK ); - - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, control); - } - /* - * No callback has been registered. Set up controller to: - * - Run - * - Stop on an error with any particular descriptor - * - Disable interrupt generation - */ - else { - control = IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base); - - control |= (ALTERA_AVALON_SGDMA_CONTROL_RUN_MSK | - ALTERA_AVALON_SGDMA_CONTROL_STOP_DMA_ER_MSK ); - control &= ~ALTERA_AVALON_SGDMA_CONTROL_IE_GLOBAL_MSK; - - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, control); - } - - /* - * Error detection/handling should be performed at the application - * or callback level as appropriate. - */ - return 0; -} - - -/* - * alt_avalon_sgdma_do_sync_transfer - * - * Send a fully formed descriptor (or list of descriptors) to SGDMA - * for transfer. This routine will block both before transfer (if the - * controller is busy), and until the requested transfer has completed. - * - * If an error is detected during the transfer it is abandoned and the - * controller's status register contents are returned to the caller. - * - * Additional error information is available in the status bits of - * each descriptor that the SGDMA processed; it is the responsibility - * of the user's application to search through the descriptor (or list - * of descriptors) to gather specific error information. - * - * Arguments: - * - *dev: Pointer to SGDMA device (instance) struct. - * - *desc: Pointer to single (ready to run) descriptor. The descriptor - * is expected to have its "next" descriptor field initialized either - * to a non-ready descriptor, or to the next in a chain. - * - * Returns: - * - status: Content of SGDMA status register. - */ -alt_u8 alt_avalon_sgdma_do_sync_transfer( - alt_sgdma_dev *dev, - alt_sgdma_descriptor *desc) -{ - alt_u8 status; - - /* Wait for any pending transfers to complete */ - while ( (IORD_ALTERA_AVALON_SGDMA_STATUS(dev->base) & - ALTERA_AVALON_SGDMA_STATUS_BUSY_MSK) ); - - - /* Clear Run */ - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, - (IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base) & - ~ALTERA_AVALON_SGDMA_CONTROL_RUN_MSK) ); - - /* - * Clear any (previous) status register information - * that might occlude our error checking later. - */ - IOWR_ALTERA_AVALON_SGDMA_STATUS(dev->base, 0xFF); - - /* Point the controller at the descriptor */ - IOWR_ALTERA_AVALON_SGDMA_NEXT_DESC_POINTER(dev->base, (alt_u32) desc); - - /* - * Set up SGDMA controller to: - * - Disable interrupt generation - * - Run once a valid descriptor is written to controller - * - Stop on an error with any particular descriptor - */ - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, - (ALTERA_AVALON_SGDMA_CONTROL_RUN_MSK | - ALTERA_AVALON_SGDMA_CONTROL_STOP_DMA_ER_MSK | - IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base)) ); - - /* Wait for the descriptor (chain) to complete */ - while ( (IORD_ALTERA_AVALON_SGDMA_STATUS(dev->base) & - ALTERA_AVALON_SGDMA_STATUS_BUSY_MSK) ); - - /* Clear Run */ - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, - (IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base) & - ~ALTERA_AVALON_SGDMA_CONTROL_RUN_MSK) ); - - /* Get & clear status register contents */ - status = IORD_ALTERA_AVALON_SGDMA_STATUS(dev->base); - IOWR_ALTERA_AVALON_SGDMA_STATUS(dev->base, 0xFF); - - return status; -} - -/* - * SGDMA Descriptor construction routines. - * - * General information: - * These routines construct a single SGDMA descriptor in the memory - * pointed to in alt_avalon_sgdma-descriptor *desc. - * - * The completed descriptor is made ready to run by setting its "Owned - * by HW" bit; once the SGDMA controller receives the descriptor (and - * its RUN bit is asserted), the descriptor will be processed. - * - * The descriptor under construction's "next" value is set to the "next" - * descriptor passed to this routine, but the "next" descriptor's "Owned - * by HW" bit is explicitly negated; once the SGDMA completes processing of - * *desc it will not continue to *next until it, too, is made ready. You - * can subsequently call the appropriate descriptor construction routine - * on *next to make it ready, too. - * - * You are responsible for the creation of both the descriptor under - * constuction as well as the "next" descriptor in the chain. - * - * Important: descriptors must be in a memory device mastered by the SGDMA - * controller's "chain read" and "chain write" Avalon master-ports. Care must be - * taken to ensure that both *desc and *next point to areas of memory mastered - * by the controller. - */ - -void alt_avalon_sgdma_construct_mem_to_mem_desc( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u32 *write_addr, - alt_u16 length, - int read_fixed, - int write_fixed) -{ - alt_avalon_sgdma_construct_mem_to_mem_desc_burst(desc, next, read_addr, - write_addr, length, read_fixed, write_fixed, 0, 0); -} -/* - * alt_avalon_sgdma_construct_mem_to_mem_desc - * - * This routine constructs a single SGDMA descriptor in the memory - * specified in alt_avalon_sgdma-descriptor *desc for an Avalon - * memory-to-memory transfer. - * - * Arguments: - * - *desc: Pointer to descriptor being constructed. - * - *next: Pointer to "next" descriptor. This need not be a complete or - * functional descriptor, but must be properly allocated as described above. - * - *read_addr: First read address for the DMA transfer - * - *write_addr: First write address for the DMA transfer - * - length: Number of bytes for this transfer - * - read_fixed: If non-zero, DMA will read from a fixed address. - * - write_fixed: If non-zer, DMA will write to a fixed address. - */ -void alt_avalon_sgdma_construct_mem_to_mem_desc_burst( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u32 *write_addr, - alt_u16 length, - int read_fixed, - int write_fixed, - int read_burst, - int write_burst) -{ - alt_avalon_sgdma_construct_descriptor_burst( - desc, - next, - read_addr, - write_addr, - length, - 0, // Generate EOP: N/A in mem-to-mem mode - read_fixed, - write_fixed, - read_burst, - write_burst, - (alt_u8) 0x0); // Atlantic channel: N/A in mem-to-mem mode -} - -void alt_avalon_sgdma_construct_stream_to_mem_desc( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *write_addr, - alt_u16 length_or_eop, - int write_fixed) -{ - alt_avalon_sgdma_construct_stream_to_mem_desc_burst(desc, next, write_addr, - length_or_eop, write_fixed, 0); -} -/* - * alt_avalon_sgdma_construct_stream_to_mem_desc - * - * This routine constructs a single SGDMA descriptor in the memory - * specified in alt_avalon_sgdma-descriptor *desc) for an Avalon - * Streaming interface-to-Avalon transfer. - * - * The source (read) data for the transfer comes from the Avalon - * Streaming Interface connected to the SGDMA controller's streaming - * read-port. - * - * Arguments: - * - *desc: Pointer to descriptor being constructed. - * - *next: Pointer to "next" descriptor. This need not be a complete or - * functional descriptor, but must be properly allocated as described above. - * - *write_addr: First write address for the DMA transfer - * - length_or_eop: Number of bytes for this transfer. If set to zero (0x0), - * the transfer will continue until an EOP signal is received from the Avalon - * Streaming interface - * - write_fixed: If non-zero, SGDMA will write to a fixed address. - */ -void alt_avalon_sgdma_construct_stream_to_mem_desc_burst( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *write_addr, - alt_u16 length_or_eop, - int write_fixed, - int write_burst) -{ - alt_avalon_sgdma_construct_descriptor_burst( - desc, - next, - (alt_u32) 0x0, // Read addr: N/A in stream-to-mem mode - write_addr, - length_or_eop, - 0x0, // Generate EOP: N/A in stream-to-mem mode - 0x0, // Read fixed: N/A in stream-to-mem mode - write_fixed, - 0, // Read_burst : N/A in stream-to-mem mode - write_burst, - (alt_u8) 0x0); // Atlantic channel: N/A in stream-to-mem mode -} - -void alt_avalon_sgdma_construct_mem_to_stream_desc( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u16 length, - int read_fixed, - int generate_sop, - int generate_eop, - alt_u8 atlantic_channel) -{ - alt_avalon_sgdma_construct_mem_to_stream_desc_burst(desc, next, read_addr, - length, read_fixed, generate_sop, generate_eop, 0, atlantic_channel); - -} -/* - * alt_avalon_sgdma_construct_mem_to_stream_desc - * - * This routine constructs a single SGDMA descriptor in the memory - * specified in alt_avalon_sgdma-descriptor *desc) for an Avalon to - * Avalon Streaming interface transfer. - * - * The destination (write) data for the transfer goes to the Avalon - * Streaming Interface connected to the SGDMA controller's streaming - * write-port. - * - * Arguments: - * - *desc: Pointer to descriptor being constructed. - * - *next: Pointer to "next" descriptor. This need not be a complete or - * functional descriptor, but must be properly allocated as described above. - * - *read_addr: First read address for the transfer - * - length: Number of bytes for this transfer - * - read_fixed: If non-zero, SGDMA will read from a fixed address. - * - generate_sop: If non-zero, SGDMA will generate a start-of-packet (SOP) - * on the Avalon Streaming interface when commencing the transfer. - * - generate_eop: If non-zero, SGDMA will generate an end-of-packet (EOP) - * on the Avalon Streaming interface when completing the transfer. - * - atlantic_channel: 8-bit channel identification number that will be - * passed to the Avalon Streaming interface. - */ -void alt_avalon_sgdma_construct_mem_to_stream_desc_burst( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u16 length, - int read_fixed, - int generate_sop, - int generate_eop, - int read_burst, - alt_u8 atlantic_channel) -{ - alt_avalon_sgdma_construct_descriptor_burst( - desc, - next, - read_addr, - (alt_u32) 0x0, // Write address N/A in mem-to-stream mode - length, - generate_eop, - read_fixed, - generate_sop, - read_burst, - 0, // Write_burst : N/A in mem-to-stream mode - atlantic_channel); -} - -/* - * alt_avalon_sgdma_register_callback - * - * Associate a user-specifiC routine with the SGDMA interrupt handler. - * If a callback is registered, all non-blocking SGDMA transfers will - * enable interrupts that will cause the callback to be executed. - * The callback runs as part of the interrupt service routine, and - * great care must be taken to follow the guidelines for acceptable - * interrupt service routine behavior as described in the Nios II - * Software Developer's Handbook. - * - * Note: To disable callbacks after registering one, this routine - * may be called passing 0x0 to the callback argument. - * - * Arguments: - * - *dev: Pointer to SGDMA device (instance) struct. - * - callback: Pointer to callback routine to execute at interrupt level - * - chain_control: SGDMA control register contents. This value will be - * OR'd together with control bits to: - * (1) Set the the SGDMA "run" bit, and - * (2) Stop SGDMA on any error - * in the SGDMA control register, when an asynchronous transfer is initiated. - * This allows you to control the conditions that will generate an interrupt - * from SGDMA. If you want interrupts to be generated (and thus call the - * callback routine), you MUST set one or more bits in the chain_control - * variable that correspond to SGDMA control register interrupt enable bits - * for interrupts to be generated, as well as the master inerrupt enable bit. - */ -void alt_avalon_sgdma_register_callback( - alt_sgdma_dev *dev, - alt_avalon_sgdma_callback callback, - alt_u32 chain_control, - void *context) -{ - dev->callback = callback; - dev->callback_context = context; - dev->chain_control = chain_control; -} - - -/* - * alt_avalon_sgdma_start - * - * Start the DMA engine. The descriptor pointed to in the controller's - * "Next descriptor pointer" and subsequent descriptor, will be processed. - * - * Arguments: - * - *dev: Pointer to SGDMA device (instance) struct. - */ -void alt_avalon_sgdma_start(alt_sgdma_dev *dev) -{ - alt_u32 control; - - control = IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base); - control |= ALTERA_AVALON_SGDMA_CONTROL_RUN_MSK; - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, control); -} - -/* - * alt_avalon_sgdma_stop - * - * Stop the DMA engine (following completion of the current buffer descriptor). - * - * Arguments: - * - *dev: Pointer to SGDMA device (instance) struct - */ -void alt_avalon_sgdma_stop(alt_sgdma_dev *dev) -{ - alt_u32 control; - - control = IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base); - control &= ~ALTERA_AVALON_SGDMA_CONTROL_RUN_MSK; - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, control); -} - -/* - * alt_avalon_sgdma_check_descriptor_status - * - * This routine will report: - * - Any errors reported by the SGDMA controller specific - * to a particular descriptor by retirning -EIO - * - The descriptor currently in use ("Owned by HW" bit set) - * by returning -EINPROGRESS. - * - * Arguments: - * - *desc: Pointer to descriptor to examine - * - * Returns: - * - 0 if the descriptor is error-free, not "owned by hardware", or - * a previously requested transfer has appeared to have completed - * normally. Or, various error conditions defined in - */ -int alt_avalon_sgdma_check_descriptor_status(alt_sgdma_descriptor *desc) -{ - /* Errors take precedence */ - if( IORD_8DIRECT(&desc->status, 0) & - ( ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_CRC_MSK | - ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_PARITY_MSK | - ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_OVERFLOW_MSK | - ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_SYNC_MSK | - ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_UEOP_MSK | - ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_MEOP_MSK | - ALTERA_AVALON_SGDMA_DESCRIPTOR_STATUS_E_MSOP_MSK ) ) { - return -EIO; - } - - if( IORD_8DIRECT(&desc->control, 0) & - ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK) { - return -EINPROGRESS; - } - - return 0; -} - -/* - * alt_avalon_sgdma_open - Retrieve a pointer to the SGDMA - * - * Search the list of registered SGDMAs for one with the supplied name. - * - * The return value will be NULL on failure, and non-NULL otherwise. - * - * Arguments: - * - *name: Character pointer to name of SGDMA peripheral as registered - * with the HAL. For example, an SGDMA controller named "my_sgdma" - * in SOPC Builder would be oped by asking for "/dev/my_sgdma". - * - * Returns: - * - Pointer to SGDMA device instance struct, or null if the device - * could not be opened. - */ -alt_sgdma_dev* alt_avalon_sgdma_open (const char* name) -{ - alt_sgdma_dev* dev; - - dev = (alt_sgdma_dev*) alt_find_dev (name, &alt_sgdma_list); - - if (NULL == dev) { - ALT_ERRNO = ENODEV; - } - - return dev; -} - - -void alt_avalon_sgdma_construct_descriptor( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u32 *write_addr, - alt_u16 length_or_eop, - int generate_eop, - int read_fixed, - int write_fixed_or_sop, - alt_u8 atlantic_channel) -{ - alt_avalon_sgdma_construct_descriptor_burst(desc, next, read_addr, - write_addr, length_or_eop, generate_eop, read_fixed, write_fixed_or_sop, - 0, 0, atlantic_channel); -} - -/* - * alt_avalon_sgdma_enable_desc_poll - * - * Enables descriptor polling mode with specified frequency. User needs to make - * sure this feature is supported by hardware. There is no effect if hardware - * does not support this feature. - * - * Arguments: - * - *dev: Pointer to SGDMA device (instance) struct - * - frequency: Frequency value to set. Only lower 11-bit value of frequency - will write to control register. - * - * Returns: - * - None - */ -void alt_avalon_sgdma_enable_desc_poll(alt_sgdma_dev *dev, alt_u32 frequency) -{ - alt_u32 control; - - control = IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base); - /* Clear descriptor polling frequency */ - control &= ~ALTERA_AVALON_SGDMA_CONTROL_DESC_POLL_FREQ_MSK; - - control |= ALTERA_AVALON_SGDMA_CONTROL_DESC_POLL_EN_MSK | - ((frequency << ALTERA_AVALON_SGDMA_CONTROL_DESC_POLL_FREQ_OFST) & - ALTERA_AVALON_SGDMA_CONTROL_DESC_POLL_FREQ_MSK); - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, control); - - return; -} - -/* - * alt_avalon_sgdma_disable_desc_poll - * - * Disables descriptor polling mode. - * - * Arguments: - * - *dev: Pointer to SGDMA device (instance) struct - * - * Returns: - * - None - */ -void alt_avalon_sgdma_disable_desc_poll(alt_sgdma_dev *dev) -{ - alt_u32 control; - - control = IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base); - control &= ~ALTERA_AVALON_SGDMA_CONTROL_DESC_POLL_EN_MSK; - - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, control); - - return; -} - -/******************************************************************************* - * Altera HAL support & Private API - ******************************************************************************/ -/* - * alt_avalon_sgdma_construct_descriptor - * - * This is a genertic routine that the SGDMA mode-specific routines - * call to populate a descriptor. - */ -void alt_avalon_sgdma_construct_descriptor_burst( - alt_sgdma_descriptor *desc, - alt_sgdma_descriptor *next, - alt_u32 *read_addr, - alt_u32 *write_addr, - alt_u16 length_or_eop, - int generate_eop, - int read_fixed, - int write_fixed_or_sop, - int read_burst, - int write_burst, - alt_u8 atlantic_channel) -{ - /* - * Mark the "next" descriptor as "not" owned by hardware. This prevents - * The SGDMA controller from continuing to process the chain. This is - * done as a single IO write to bypass cache, without flushing - * the entire descriptor, since only the 8-bit descriptor status must - * be flushed. - */ - IOWR_8DIRECT(&next->control, 0, - (next->control & ~ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK)); - - desc->read_addr = read_addr; - desc->write_addr = write_addr; - desc->next = (alt_u32 *) next; - desc->read_addr_pad = 0x0; - desc->write_addr_pad = 0x0; - desc->next_pad = 0x0; - desc->bytes_to_transfer = length_or_eop; - desc->actual_bytes_transferred = 0; - desc->status = 0x0; - - /* SGDMA burst not currently supported */ - desc->read_burst = read_burst; - desc->write_burst = write_burst; - - /* - * Set the descriptor control block as follows: - * - Set "owned by hardware" bit - * - Optionally set "generte EOP" bit - * - Optionally set the "read from fixed address" bit - * - Optionally set the "write to fixed address bit (which serves - * serves as a "generate SOP" control bit in memory-to-stream mode). - * - Set the 4-bit atlantic channel, if specified - * - * Note that this step is performed after all other descriptor information - * has been filled out so that, if the controller already happens to be - * pointing at this descriptor, it will not run (via the "owned by hardware" - * bit) until all other descriptor information has been set up. - */ - desc->control = ( - (ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK) | - (generate_eop ? - ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_GENERATE_EOP_MSK : 0x0) | - (read_fixed ? - ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_READ_FIXED_ADDRESS_MSK : 0x0) | - (write_fixed_or_sop ? - ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_WRITE_FIXED_ADDRESS_MSK : 0x0) | - (atlantic_channel ? ( (atlantic_channel & 0x0F) << 3) : 0) - ); - - /* - * Flush completed buffer out of cache. This is done rather than - * individual cache-bypassed writes to take advantage of any - * burst-capabilities in the memory we're writing to. - */ - alt_dcache_flush(desc, sizeof(alt_sgdma_descriptor)); -} - -/* - * alt_avalon_sgdma_irq() - * - * Interrupt handler for the Scatter-Gather DMA controller. - */ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT -static void alt_avalon_sgdma_irq(void *context) -#else -static void alt_avalon_sgdma_irq(void *context, alt_u32 id) -#endif -{ - alt_sgdma_dev *dev = (alt_sgdma_dev *) context; - alt_irq_context cpu_sr; - - /* - * Clear the pending interrupt request from the SGDMA controller. - * Writing 1 to bit-31 of the control register clears the interrupt. - * Note: This is explicitly done before calling user interrupt-handling - * code rather than after; if user ISR code initiates another SGDMA - * transfer which completes quickly, reading the control register after - * the callback routine may result in a lost interrupt. - */ - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, - IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base) | 0x80000000); - - /* Dummy read to ensure IRQ is negated before the ISR returns */ - IORD_ALTERA_AVALON_SGDMA_CONTROL(dev->base); - - /* - * Other interrupts are explicitly disabled if callbacks - * are registered because there is no guarantee that they are - * preemption-safe. This allows the driver to support - * interrupt preemption. - */ - if(dev->callback) { - cpu_sr = alt_irq_disable_all(); - (dev->callback)(dev->callback_context); - alt_irq_enable_all(cpu_sr); - } -} - -/* - * alt_avalon_sgdma_init() - * - * Initializes the Scatter-Gather DMA controller. This routine is called - * from the ALTERA_AVALON_SGDMA_INIT macro and is called automatically - * by alt_sys_init.c - * - * This routine disables interrupts, future descriptor processing, - * registers a specific instance of the device with the HAL, - * and installs an interrupt handler for the device. - */ -void alt_avalon_sgdma_init (alt_sgdma_dev *dev, alt_u32 ic_id, alt_u32 irq) -{ - extern alt_llist alt_sgdma_list; - - /* - * Halt any current transactions (reset the device) - * SW reset is written twice per SGDMA documentation - */ - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, - ALTERA_AVALON_SGDMA_CONTROL_SOFTWARERESET_MSK); - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, - ALTERA_AVALON_SGDMA_CONTROL_SOFTWARERESET_MSK); - - /* - * Disable interrupts, halt future descriptor processing, - * and clear status register content - */ - IOWR_ALTERA_AVALON_SGDMA_CONTROL(dev->base, 0x0); - IOWR_ALTERA_AVALON_SGDMA_STATUS(dev->base, 0xFF); - - /* Register this instance of the SGDMA controller with HAL */ - alt_dev_llist_insert((alt_dev_llist*) dev, &alt_sgdma_list); - - /* Install IRQ handler */ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT - alt_ic_isr_register(ic_id, irq, alt_avalon_sgdma_irq, dev, 0x0); -#else - alt_irq_register(irq, dev, alt_avalon_sgdma_irq); -#endif -} diff --git a/ext/hal/altera/drivers/altera_avalon_sgdma/inc/altera_avalon_sgdma_regs.h b/ext/hal/altera/drivers/altera_avalon_sgdma/inc/altera_avalon_sgdma_regs.h deleted file mode 100644 index 1e7f9b4ef4..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_sgdma/inc/altera_avalon_sgdma_regs.h +++ /dev/null @@ -1,93 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2011 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALTERA_AVALON_SGDMA_REGS_H__ -#define __ALTERA_AVALON_SGDMA_REGS_H__ - -#include - -#define IOADDR_ALTERA_AVALON_SGDMA_STATUS(base) __IO_CALC_ADDRESS_DYNAMIC(base, 0) -#define IORD_ALTERA_AVALON_SGDMA_STATUS(base) IORD(base, 0) -#define IOWR_ALTERA_AVALON_SGDMA_STATUS(base, data) IOWR(base, 0, data) - -#define ALTERA_AVALON_SGDMA_STATUS_ERROR_MSK (0x1) -#define ALTERA_AVALON_SGDMA_STATUS_ERROR_OFST (0) -#define ALTERA_AVALON_SGDMA_STATUS_EOP_ENCOUNTERED_MSK (0x2) -#define ALTERA_AVALON_SGDMA_STATUS_EOP_ENCOUNTERED_OFST (1) -#define ALTERA_AVALON_SGDMA_STATUS_DESC_COMPLETED_MSK (0x4) -#define ALTERA_AVALON_SGDMA_STATUS_DESC_COMPLETED_OFST (2) -#define ALTERA_AVALON_SGDMA_STATUS_CHAIN_COMPLETED_MSK (0x8) -#define ALTERA_AVALON_SGDMA_STATUS_CHAIN_COMPLETED_OFST (3) -#define ALTERA_AVALON_SGDMA_STATUS_BUSY_MSK (0x10) -#define ALTERA_AVALON_SGDMA_STATUS_BUSY_OFST (4) - -#define IOADDR_ALTERA_AVALON_SGDMA_VERSION(base) __IO_CALC_ADDRESS_DYNAMIC(base, 1) -#define IORD_ALTERA_AVALON_SGDMA_VERSION(base) IORD(base, 1) -#define IOWR_ALTERA_AVALON_SGDMA_VERSION(base, data) IOWR(base, 1, data) -#define ALTERA_AVALON_SGDMA_VERSION_VERSION_MSK (0xFFFF) -#define ALTERA_AVALON_SGDMA_VERSION_VERSION_OFST (0) - - -#define IOADDR_ALTERA_AVALON_SGDMA_CONTROL(base) __IO_CALC_ADDRESS_DYNAMIC(base, 4) -#define IORD_ALTERA_AVALON_SGDMA_CONTROL(base) IORD(base, 4) -#define IOWR_ALTERA_AVALON_SGDMA_CONTROL(base, data) IOWR(base, 4, data) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_ERROR_MSK (0x1) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_ERROR_OFST (0) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_EOP_ENCOUNTERED_MSK (0x2) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_EOP_ENCOUNTERED_OFST (1) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_DESC_COMPLETED_MSK (0x4) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_DESC_COMPLETED_OFST (2) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_CHAIN_COMPLETED_MSK (0x8) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_CHAIN_COMPLETED_OFST (3) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_GLOBAL_MSK (0x10) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_GLOBAL_OFST (4) -#define ALTERA_AVALON_SGDMA_CONTROL_RUN_MSK (0x20) -#define ALTERA_AVALON_SGDMA_CONTROL_RUN_OFST (5) -#define ALTERA_AVALON_SGDMA_CONTROL_STOP_DMA_ER_MSK (0x40) -#define ALTERA_AVALON_SGDMA_CONTROL_STOP_DMA_ER_OFST (6) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_MAX_DESC_PROCESSED_MSK (0x80) -#define ALTERA_AVALON_SGDMA_CONTROL_IE_MAX_DESC_PROCESSED_OFST (7) -#define ALTERA_AVALON_SGDMA_CONTROL_MAX_DESC_PROCESSED_MSK (0xFF00) -#define ALTERA_AVALON_SGDMA_CONTROL_MAX_DESC_PROCESSED_OFST (8) -#define ALTERA_AVALON_SGDMA_CONTROL_SOFTWARERESET_MSK (0X10000) -#define ALTERA_AVALON_SGDMA_CONTROL_SOFTWARERESET_OFST (16) -#define ALTERA_AVALON_SGDMA_CONTROL_PARK_MSK (0X20000) -#define ALTERA_AVALON_SGDMA_CONTROL_PARK_OFST (17) -#define ALTERA_AVALON_SGDMA_CONTROL_DESC_POLL_EN_MSK (0X40000) -#define ALTERA_AVALON_SGDMA_CONTROL_DESC_POLL_EN_OFST (18) -#define ALTERA_AVALON_SGDMA_CONTROL_DESC_POLL_FREQ_MSK (0x7FF00000) -#define ALTERA_AVALON_SGDMA_CONTROL_DESC_POLL_FREQ_OFST (20) -#define ALTERA_AVALON_SGDMA_CONTROL_CLEAR_INTERRUPT_MSK (0X80000000) -#define ALTERA_AVALON_SGDMA_CONTROL_CLEAR_INTERRUPT_OFST (31) - -#define IOADDR_ALTERA_AVALON_SGDMA_NEXT_DESC_POINTER(base) __IO_CALC_ADDRESS_DYNAMIC(base, 8) -#define IORD_ALTERA_AVALON_SGDMA_NEXT_DESC_POINTER(base) IORD(base, 8) -#define IOWR_ALTERA_AVALON_SGDMA_NEXT_DESC_POINTER(base, data) IOWR(base, 8, data) - - -#endif /* __ALTERA_AVALON_SGDMA_REGS_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_spi/HAL/inc/altera_avalon_spi.h b/ext/hal/altera/drivers/altera_avalon_spi/HAL/inc/altera_avalon_spi.h deleted file mode 100644 index fe946b82cb..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_spi/HAL/inc/altera_avalon_spi.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef __ALT_AVALON_SPI_H__ -#define __ALT_AVALON_SPI_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ -#include - -#include "alt_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * Macros used by alt_sys_init - */ - -#define ALTERA_AVALON_SPI_INSTANCE(name, device) extern int alt_no_storage -#define ALTERA_AVALON_SPI_INIT(name, device) while (0) - -/* - * Use this function to perform one SPI access on your target. 'base' should - * be the base address of your SPI peripheral, while 'slave' indicates which - * bit in the slave select register should be set. - */ - -/* If you need to make multiple accesses to the same slave then you should - * set the merge bit in the flags for all of them except the first. - */ -#define ALT_AVALON_SPI_COMMAND_MERGE (0x01) - -/* - * If you need the slave select line to be toggled between words then you - * should set the toggle bit in the flag. - */ -#define ALT_AVALON_SPI_COMMAND_TOGGLE_SS_N (0x02) - - -int alt_avalon_spi_command(alt_u32 base, alt_u32 slave, - alt_u32 write_length, const alt_u8 * write_data, - alt_u32 read_length, alt_u8 * read_data, - alt_u32 flags); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_AVALON_SPI_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_spi/HAL/src/CMakeLists.txt b/ext/hal/altera/drivers/altera_avalon_spi/HAL/src/CMakeLists.txt deleted file mode 100644 index 1f423a265c..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_spi/HAL/src/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -zephyr_sources(altera_avalon_spi.c) diff --git a/ext/hal/altera/drivers/altera_avalon_spi/HAL/src/altera_avalon_spi.c b/ext/hal/altera/drivers/altera_avalon_spi/HAL/src/altera_avalon_spi.c deleted file mode 100644 index 4a1ef38ab1..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_spi/HAL/src/altera_avalon_spi.c +++ /dev/null @@ -1,132 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include "alt_types.h" - -#include "altera_avalon_spi_regs.h" -#include "altera_avalon_spi.h" - -/* This is a very simple routine which performs one SPI master transaction. - * It would be possible to implement a more efficient version using interrupts - * and sleeping threads but this is probably not worthwhile initially. - */ - -int alt_avalon_spi_command(alt_u32 base, alt_u32 slave, - alt_u32 write_length, const alt_u8 * write_data, - alt_u32 read_length, alt_u8 * read_data, - alt_u32 flags) -{ - const alt_u8 * write_end = write_data + write_length; - alt_u8 * read_end = read_data + read_length; - - alt_u32 write_zeros = read_length; - alt_u32 read_ignore = write_length; - alt_u32 status; - - /* We must not send more than two bytes to the target before it has - * returned any as otherwise it will overflow. */ - /* Unfortunately the hardware does not seem to work with credits > 1, - * leave it at 1 for now. */ - alt_32 credits = 1; - - /* Warning: this function is not currently safe if called in a multi-threaded - * environment, something above must perform locking to make it safe if more - * than one thread intends to use it. - */ - - IOWR_ALTERA_AVALON_SPI_SLAVE_SEL(base, 1 << slave); - - /* Set the SSO bit (force chipselect) only if the toggle flag is not set */ - if ((flags & ALT_AVALON_SPI_COMMAND_TOGGLE_SS_N) == 0) { - IOWR_ALTERA_AVALON_SPI_CONTROL(base, ALTERA_AVALON_SPI_CONTROL_SSO_MSK); - } - - /* - * Discard any stale data present in the RXDATA register, in case - * previous communication was interrupted and stale data was left - * behind. - */ - IORD_ALTERA_AVALON_SPI_RXDATA(base); - - /* Keep clocking until all the data has been processed. */ - for ( ; ; ) - { - - do - { - status = IORD_ALTERA_AVALON_SPI_STATUS(base); - } - while (((status & ALTERA_AVALON_SPI_STATUS_TRDY_MSK) == 0 || credits == 0) && - (status & ALTERA_AVALON_SPI_STATUS_RRDY_MSK) == 0); - - if ((status & ALTERA_AVALON_SPI_STATUS_TRDY_MSK) != 0 && credits > 0) - { - credits--; - - if (write_data < write_end) - IOWR_ALTERA_AVALON_SPI_TXDATA(base, *write_data++); - else if (write_zeros > 0) - { - write_zeros--; - IOWR_ALTERA_AVALON_SPI_TXDATA(base, 0); - } - else - credits = -1024; - }; - - if ((status & ALTERA_AVALON_SPI_STATUS_RRDY_MSK) != 0) - { - alt_u32 rxdata = IORD_ALTERA_AVALON_SPI_RXDATA(base); - - if (read_ignore > 0) - read_ignore--; - else - *read_data++ = (alt_u8)rxdata; - credits++; - - if (read_ignore == 0 && read_data == read_end) - break; - } - - } - - /* Wait until the interface has finished transmitting */ - do - { - status = IORD_ALTERA_AVALON_SPI_STATUS(base); - } - while ((status & ALTERA_AVALON_SPI_STATUS_TMT_MSK) == 0); - - /* Clear SSO (release chipselect) unless the caller is going to - * keep using this chip - */ - if ((flags & ALT_AVALON_SPI_COMMAND_MERGE) == 0) - IOWR_ALTERA_AVALON_SPI_CONTROL(base, 0); - - return read_length; -} diff --git a/ext/hal/altera/drivers/altera_avalon_spi/inc/altera_avalon_spi_regs.h b/ext/hal/altera/drivers/altera_avalon_spi/inc/altera_avalon_spi_regs.h deleted file mode 100644 index 67d4dafa21..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_spi/inc/altera_avalon_spi_regs.h +++ /dev/null @@ -1,85 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALTERA_AVALON_SPI_REGS_H__ -#define __ALTERA_AVALON_SPI_REGS_H__ - -#include - -#define ALTERA_AVALON_SPI_RXDATA_REG 0 -#define IOADDR_ALTERA_AVALON_SPI_RXDATA(base) __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_SPI_RXDATA_REG) -#define IORD_ALTERA_AVALON_SPI_RXDATA(base) IORD(base, ALTERA_AVALON_SPI_RXDATA_REG) -#define IOWR_ALTERA_AVALON_SPI_RXDATA(base, data) IOWR(base, ALTERA_AVALON_SPI_RXDATA_REG, data) - -#define ALTERA_AVALON_SPI_TXDATA_REG 1 -#define IOADDR_ALTERA_AVALON_SPI_TXDATA(base) __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_SPI_TXDATA_REG) -#define IORD_ALTERA_AVALON_SPI_TXDATA(base) IORD(base, ALTERA_AVALON_SPI_TXDATA_REG) -#define IOWR_ALTERA_AVALON_SPI_TXDATA(base, data) IOWR(base, ALTERA_AVALON_SPI_TXDATA_REG, data) - -#define ALTERA_AVALON_SPI_STATUS_REG 2 -#define IOADDR_ALTERA_AVALON_SPI_STATUS(base) __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_SPI_STATUS_REG) -#define IORD_ALTERA_AVALON_SPI_STATUS(base) IORD(base, ALTERA_AVALON_SPI_STATUS_REG) -#define IOWR_ALTERA_AVALON_SPI_STATUS(base, data) IOWR(base, ALTERA_AVALON_SPI_STATUS_REG, data) - -#define ALTERA_AVALON_SPI_STATUS_ROE_MSK (0x8) -#define ALTERA_AVALON_SPI_STATUS_ROE_OFST (3) -#define ALTERA_AVALON_SPI_STATUS_TOE_MSK (0x10) -#define ALTERA_AVALON_SPI_STATUS_TOE_OFST (4) -#define ALTERA_AVALON_SPI_STATUS_TMT_MSK (0x20) -#define ALTERA_AVALON_SPI_STATUS_TMT_OFST (5) -#define ALTERA_AVALON_SPI_STATUS_TRDY_MSK (0x40) -#define ALTERA_AVALON_SPI_STATUS_TRDY_OFST (6) -#define ALTERA_AVALON_SPI_STATUS_RRDY_MSK (0x80) -#define ALTERA_AVALON_SPI_STATUS_RRDY_OFST (7) -#define ALTERA_AVALON_SPI_STATUS_E_MSK (0x100) -#define ALTERA_AVALON_SPI_STATUS_E_OFST (8) - -#define ALTERA_AVALON_SPI_CONTROL_REG 3 -#define IOADDR_ALTERA_AVALON_SPI_CONTROL(base) __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_SPI_CONTROL_REG) -#define IORD_ALTERA_AVALON_SPI_CONTROL(base) IORD(base, ALTERA_AVALON_SPI_CONTROL_REG) -#define IOWR_ALTERA_AVALON_SPI_CONTROL(base, data) IOWR(base, ALTERA_AVALON_SPI_CONTROL_REG, data) - -#define ALTERA_AVALON_SPI_CONTROL_IROE_MSK (0x8) -#define ALTERA_AVALON_SPI_CONTROL_IROE_OFST (3) -#define ALTERA_AVALON_SPI_CONTROL_ITOE_MSK (0x10) -#define ALTERA_AVALON_SPI_CONTROL_ITOE_OFST (4) -#define ALTERA_AVALON_SPI_CONTROL_ITRDY_MSK (0x40) -#define ALTERA_AVALON_SPI_CONTROL_ITRDY_OFS (6) -#define ALTERA_AVALON_SPI_CONTROL_IRRDY_MSK (0x80) -#define ALTERA_AVALON_SPI_CONTROL_IRRDY_OFS (7) -#define ALTERA_AVALON_SPI_CONTROL_IE_MSK (0x100) -#define ALTERA_AVALON_SPI_CONTROL_IE_OFST (8) -#define ALTERA_AVALON_SPI_CONTROL_SSO_MSK (0x400) -#define ALTERA_AVALON_SPI_CONTROL_SSO_OFST (10) - -#define ALTERA_AVALON_SPI_SLAVE_SEL_REG 5 -#define IOADDR_ALTERA_AVALON_SPI_SLAVE_SEL(base) __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_SPI_SLAVE_SEL_REG) -#define IORD_ALTERA_AVALON_SPI_SLAVE_SEL(base) IORD(base, ALTERA_AVALON_SPI_SLAVE_SEL_REG) -#define IOWR_ALTERA_AVALON_SPI_SLAVE_SEL(base, data) IOWR(base, ALTERA_AVALON_SPI_SLAVE_SEL_REG, data) - -#endif /* __ALTERA_AVALON_SPI_REGS_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_sysid/HAL/inc/altera_avalon_sysid.h b/ext/hal/altera/drivers/altera_avalon_sysid/HAL/inc/altera_avalon_sysid.h deleted file mode 100644 index 54df971827..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_sysid/HAL/inc/altera_avalon_sysid.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef __ALT_AVALON_SYSID_H__ -#define __ALT_AVALON_SYSID_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -#include "alt_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * ALTERA_AVALON_SYSID_INSTANCE is the macro used by alt_sys_init() to - * allocate any per device memory that may be required. In this case no - * allocation is necessary. - */ - -#define ALTERA_AVALON_SYSID_INSTANCE(name, dev) extern int alt_no_storage -#define ALTERA_AVALON_SYSID_INIT(name, dev) while (0) - -#ifdef SYSID_BASE -alt_32 alt_avalon_sysid_test(void); -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_AVALON_SYSID_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_sysid/HAL/src/CMakeLists.txt b/ext/hal/altera/drivers/altera_avalon_sysid/HAL/src/CMakeLists.txt deleted file mode 100644 index fd85585f9b..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_sysid/HAL/src/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -zephyr_sources(altera_avalon_sysid.c) diff --git a/ext/hal/altera/drivers/altera_avalon_sysid/HAL/src/altera_avalon_sysid.c b/ext/hal/altera/drivers/altera_avalon_sysid/HAL/src/altera_avalon_sysid.c deleted file mode 100644 index 578b29d480..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_sysid/HAL/src/altera_avalon_sysid.c +++ /dev/null @@ -1,80 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -#include "altera_avalon_sysid.h" -#include "altera_avalon_sysid_regs.h" -#include "alt_types.h" -#include - -/* -* This component is special: there's only one of it. -* Therefore we can dispense with a bunch of complexity -* normally associated with components, such as specialized -* structs containing parameter info, and instead use that -* info by name directly out of system.h. A downside of this -* approach is that each time the system is regenerated, and -* system.h changes, this file must be recompiled. Fortunately -* this file is, and is likely to remain, quite small. -*/ -#include "system.h" - -#ifdef SYSID_BASE -/* -* return values: -* 0 if the hardware and software appear to be in sync -* 1 if software appears to be older than hardware -* -1 if hardware appears to be older than software -*/ - -alt_32 alt_avalon_sysid_test(void) -{ - /* Read the hardware-tag, aka value0, from the hardware. */ - alt_u32 hardware_id = IORD_ALTERA_AVALON_SYSID_ID(SYSID_BASE); - - /* Read the time-of-generation, aka value1, from the hardware register. */ - alt_u32 hardware_timestamp = IORD_ALTERA_AVALON_SYSID_TIMESTAMP(SYSID_BASE); - - /* Return 0 if the hardware and software appear to be in sync. */ - if ((SYSID_TIMESTAMP == hardware_timestamp) && (SYSID_ID == hardware_id)) - { - return 0; - } - - /* - * Return 1 if software appears to be older than hardware (that is, - * the value returned by the hardware is larger than that recorded by - * the generator function). - * If the hardware time happens to match the generator program's value - * (but the hardware tag, value0, doesn't match or 0 would have been - * returned above), return an arbitrary value, let's say -1. - */ - return ((alt_32)(hardware_timestamp - SYSID_TIMESTAMP)) > 0 ? 1 : -1; -} -#endif diff --git a/ext/hal/altera/drivers/altera_avalon_sysid/HAL/src/component.mk b/ext/hal/altera/drivers/altera_avalon_sysid/HAL/src/component.mk deleted file mode 100644 index 9f5c072d82..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_sysid/HAL/src/component.mk +++ /dev/null @@ -1,37 +0,0 @@ -# ******************************************************************************* -# * * -# * License Agreement * -# * * -# * Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -# * All rights reserved. * -# * * -# * Permission is hereby granted, free of charge, to any person obtaining a * -# * copy of this software and associated documentation files (the "Software"), * -# * to deal in the Software without restriction, including without limitation * -# * the rights to use, copy, modify, merge, publish, distribute, sublicense, * -# * and/or sell copies of the Software, and to permit persons to whom the * -# * Software is furnished to do so, subject to the following conditions: * -# * * -# * The above copyright notice and this permission notice shall be included in * -# * all copies or substantial portions of the Software. * -# * * -# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -# * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -# * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -# * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -# * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -# * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -# * DEALINGS IN THE SOFTWARE. * -# * * -# * * -# * Altera does not recommend, suggest or require that this reference design * -# * file be used in conjunction or combination with any other product. * -# ******************************************************************************* - -# List all source files supplied by this component. - -C_LIB_SRCS += altera_avalon_sysid.c - -ASM_LIB_SRCS += - -INCLUDE_PATH += diff --git a/ext/hal/altera/drivers/altera_avalon_sysid/inc/altera_avalon_sysid_regs.h b/ext/hal/altera/drivers/altera_avalon_sysid/inc/altera_avalon_sysid_regs.h deleted file mode 100644 index 8d3987d893..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_sysid/inc/altera_avalon_sysid_regs.h +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALTERA_AVALON_SYSID_REGS_H__ -#define __ALTERA_AVALON_SYSID_REGS_H__ - -#include - -#define IOADDR_ALTERA_AVALON_SYSID_ID(base) __IO_CALC_ADDRESS_NATIVE(base, 0) -#define IORD_ALTERA_AVALON_SYSID_ID(base) IORD(base, 0) - -#define IOADDR_ALTERA_AVALON_SYSID_TIMESTAMP(base) __IO_CALC_ADDRESS_NATIVE(base, 1) -#define IORD_ALTERA_AVALON_SYSID_TIMESTAMP(base) IORD(base, 1) - -#endif /* __ALTERA_AVALON_SYSID_REGS_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_timer/HAL/inc/altera_avalon_timer.h b/ext/hal/altera/drivers/altera_avalon_timer/HAL/inc/altera_avalon_timer.h deleted file mode 100644 index 60b2f0a597..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_timer/HAL/inc/altera_avalon_timer.h +++ /dev/null @@ -1,191 +0,0 @@ -#ifndef __ALT_AVALON_TIMER_H__ -#define __ALT_AVALON_TIMER_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -#include - -#include "alt_types.h" -#include "sys/alt_dev.h" -#include "sys/alt_warning.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - - -#define __ALT_COUNTER_SIZE(name) name##_COUNTER_SIZE -#define _ALT_COUNTER_SIZE(name) __ALT_COUNTER_SIZE(name) - -#define ALT_SYS_CLK_COUNTER_SIZE _ALT_COUNTER_SIZE(ALT_SYS_CLK) -#define ALT_TIMESTAMP_COUNTER_SIZE _ALT_COUNTER_SIZE(ALT_TIMESTAMP_CLK) - -#if (ALT_SYS_CLK_COUNTER_SIZE == 64) -#define alt_sysclk_type alt_u64 -#else -#define alt_sysclk_type alt_u32 -#endif - -#if (ALT_TIMESTAMP_COUNTER_SIZE == 64) -#define alt_timestamp_type alt_u64 -#else -#define alt_timestamp_type alt_u32 -#endif - -/* - * The function alt_avalon_timer_sc_init() is the initialisation function for - * the system clock. It registers the timers interrupt handler, and then calls - * the system clock regestration function, alt_sysclk_init(). - */ - -extern void alt_avalon_timer_sc_init (void* base, alt_u32 irq_controller_id, - alt_u32 irq, alt_u32 freq); - -/* - * Variables used to store the timestamp parameters, when the device is to be - * accessed using the high resolution timestamp driver. - */ - -extern void* altera_avalon_timer_ts_base; -extern alt_u32 altera_avalon_timer_ts_freq; - -/* - * ALTERA_AVALON_TIMER_INSTANCE is the macro used by alt_sys_init() to - * allocate any per device memory that may be required. In this case no - * allocation is necessary. - */ - -#define ALTERA_AVALON_TIMER_INSTANCE(name, dev) extern int alt_no_storage - -/* - * Macro used to calculate the timer interrupt frequency. Although this is - * somewhat fearsome, when compiled with -O2 it will be resolved at compile - * time to a constant value. - */ - -#define ALTERA_AVALON_TIMER_FREQ(freq, period, units) \ - strcmp (units, "us") ? \ - (strcmp (units, "ms") ? \ - (strcmp (units, "s") ? \ - ((freq + (period - 1))/period) \ - : 1) \ - : (1000 + (period - 1))/period) \ - : ((1000000 + (period - 1))/period) - -/* - * Construct macros which contain the base address of the system clock and the - * timestamp device. These are used below to determine which driver to use for - * a given timer. - */ - -#define __ALT_CLK_BASE(name) name##_BASE -#define _ALT_CLK_BASE(name) __ALT_CLK_BASE(name) - -#define ALT_SYS_CLK_BASE _ALT_CLK_BASE(ALT_SYS_CLK) -#define ALT_TIMESTAMP_CLK_BASE _ALT_CLK_BASE(ALT_TIMESTAMP_CLK) - -/* - * If there is no system clock, then the above macro will result in - * ALT_SYS_CLK_BASE being set to none_BASE. We therefore need to provide an - * invalid value for this, so that no timer is wrongly identified as the system - * clock. - */ - -#define none_BASE 0xffffffff - -/* - * ALTERA_AVALON_TIMER_INIT is the macro used by alt_sys_init() to provide - * the run time initialisation of the device. In this case this translates to - * a call to alt_avalon_timer_sc_init() if the device is the system clock, i.e. - * if it has the name "sysclk". - * - * If the device is not the system clock, then it is used to provide the - * timestamp facility. - * - * To ensure as much as possible is evaluated at compile time, rather than - * compare the name of the device to "/dev/sysclk" using strcmp(), the base - * address of the device is compared to SYSCLK_BASE to determine whether it's - * the system clock. Since the base address of a device must be unique, these - * two aproaches are equivalent. - * - * This macro performs a sanity check to ensure that the interrupt has been - * connected for this device. If not, then an apropriate error message is - * generated at build time. - */ - - -#define ALTERA_AVALON_TIMER_INIT(name, dev) \ - if (name##_BASE == ALT_SYS_CLK_BASE) \ - { \ - if (name##_IRQ == ALT_IRQ_NOT_CONNECTED) \ - { \ - ALT_LINK_ERROR ("Error: Interrupt not connected for " #dev ". " \ - "The system clock driver requires an interrupt to be " \ - "connected. Please select an IRQ for this device in " \ - "SOPC builder."); \ - } \ - else \ - { \ - alt_avalon_timer_sc_init((void*) name##_BASE, \ - name##_IRQ_INTERRUPT_CONTROLLER_ID, \ - name##_IRQ, \ - ALTERA_AVALON_TIMER_FREQ(name##_FREQ, \ - name##_PERIOD, \ - name##_PERIOD_UNITS));\ - } \ - } \ - else if (name##_BASE == ALT_TIMESTAMP_CLK_BASE) \ - { \ - if (name##_SNAPSHOT) \ - { \ - altera_avalon_timer_ts_base = (void*) name##_BASE; \ - altera_avalon_timer_ts_freq = name##_FREQ; \ - } \ - else \ - { \ - ALT_LINK_ERROR ("Error: Snapshot register not available for " \ - #dev ". " \ - "The timestamp driver requires the snapshot register " \ - "to be readable. Please enable this register for this " \ - "device in SOPC builder."); \ - } \ - } - -/* - * - */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_AVALON_TIMER_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/CMakeLists.txt b/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/CMakeLists.txt deleted file mode 100644 index f283dbc8b1..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -zephyr_sources( - altera_avalon_timer_sc.c - altera_avalon_timer_ts.c - altera_avalon_timer_vars.c - ) diff --git a/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/altera_avalon_timer_sc.c b/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/altera_avalon_timer_sc.c deleted file mode 100644 index c1d7e97600..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/altera_avalon_timer_sc.c +++ /dev/null @@ -1,108 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -#include - -#include "sys/alt_alarm.h" -#include "sys/alt_irq.h" - -#include "altera_avalon_timer.h" -#include "altera_avalon_timer_regs.h" - -#include "alt_types.h" -#include "sys/alt_log_printf.h" - -/* - * alt_avalon_timer_sc_irq() is the interrupt handler used for the system - * clock. This is called periodically when a timer interrupt occurs. The - * function first clears the interrupt condition, and then calls the - * alt_tick() function to notify the system that a timer tick has occurred. - * - * alt_tick() increments the system tick count, and updates any registered - * alarms, see alt_tick.c for further details. - */ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT -static void alt_avalon_timer_sc_irq (void* base) -#else -static void alt_avalon_timer_sc_irq (void* base, alt_u32 id) -#endif -{ - alt_irq_context cpu_sr; - - /* clear the interrupt */ - IOWR_ALTERA_AVALON_TIMER_STATUS (base, 0); - - /* - * Dummy read to ensure IRQ is negated before the ISR returns. - * The control register is read because reading the status - * register has side-effects per the register map documentation. - */ - IORD_ALTERA_AVALON_TIMER_CONTROL (base); - - /* ALT_LOG - see altera_hal/HAL/inc/sys/alt_log_printf.h */ - ALT_LOG_SYS_CLK_HEARTBEAT(); - - /* - * Notify the system of a clock tick. disable interrupts - * during this time to safely support ISR preemption - */ - cpu_sr = alt_irq_disable_all(); - alt_tick (); - alt_irq_enable_all(cpu_sr); -} - -/* - * alt_avalon_timer_sc_init() is called to initialise the timer that will be - * used to provide the periodic system clock. This is called from the - * auto-generated alt_sys_init() function. - */ - -void alt_avalon_timer_sc_init (void* base, alt_u32 irq_controller_id, - alt_u32 irq, alt_u32 freq) -{ - /* set the system clock frequency */ - - alt_sysclk_init (freq); - - /* set to free running mode */ - - IOWR_ALTERA_AVALON_TIMER_CONTROL (base, - ALTERA_AVALON_TIMER_CONTROL_ITO_MSK | - ALTERA_AVALON_TIMER_CONTROL_CONT_MSK | - ALTERA_AVALON_TIMER_CONTROL_START_MSK); - - /* register the interrupt handler, and enable the interrupt */ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT - alt_ic_isr_register(irq_controller_id, irq, alt_avalon_timer_sc_irq, - base, NULL); -#else - alt_irq_register (irq, base, alt_avalon_timer_sc_irq); -#endif -} diff --git a/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/altera_avalon_timer_ts.c b/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/altera_avalon_timer_ts.c deleted file mode 100644 index c1ad3f5d80..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/altera_avalon_timer_ts.c +++ /dev/null @@ -1,141 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -#include - -#include "system.h" -#include "sys/alt_timestamp.h" - -#include "altera_avalon_timer.h" -#include "altera_avalon_timer_regs.h" - -#include "alt_types.h" - -/* - * These functions are only available if a timestamp device has been selected - * for this system. - */ - -#if (ALT_TIMESTAMP_CLK_BASE != none_BASE) - -/* - * The function alt_timestamp_start() can be called at application level to - * initialise the timestamp facility. In this case the period register is - * set to full scale, i.e. 0xffffffff, and then started running. Note that - * the period register may not be writable, depending on the hardware - * configuration, in which case this function does not reset the period. - * - * The timer is not run in continuous mode, so that the user can detect timer - * roll-over, i.e. alt_timestamp() returns 0. - * - * The return value of this function is 0 upon sucess and -1 if in timestamp - * device has not been registered. - */ - -int alt_timestamp_start(void) -{ - void* base = altera_avalon_timer_ts_base; - - if (!altera_avalon_timer_ts_freq) - { - return -1; - } - else - { - if(ALT_TIMESTAMP_COUNTER_SIZE == 64) { - IOWR_ALTERA_AVALON_TIMER_CONTROL (base,ALTERA_AVALON_TIMER_CONTROL_STOP_MSK); - IOWR_ALTERA_AVALON_TIMER_PERIOD_0 (base, 0xFFFF); - IOWR_ALTERA_AVALON_TIMER_PERIOD_1 (base, 0xFFFF);; - IOWR_ALTERA_AVALON_TIMER_PERIOD_2 (base, 0xFFFF); - IOWR_ALTERA_AVALON_TIMER_PERIOD_3 (base, 0xFFFF); - IOWR_ALTERA_AVALON_TIMER_CONTROL (base, ALTERA_AVALON_TIMER_CONTROL_START_MSK); - } else { - IOWR_ALTERA_AVALON_TIMER_CONTROL (base,ALTERA_AVALON_TIMER_CONTROL_STOP_MSK); - IOWR_ALTERA_AVALON_TIMER_PERIODL (base, 0xFFFF); - IOWR_ALTERA_AVALON_TIMER_PERIODH (base, 0xFFFF); - IOWR_ALTERA_AVALON_TIMER_CONTROL (base, ALTERA_AVALON_TIMER_CONTROL_START_MSK); - } - } - return 0; -} - -/* - * alt_timestamp() returns the current timestamp count. In the event that - * the timer has run full period, or there is no timestamp available, this - * function return -1. - * - * The returned timestamp counts up from the last time the period register - * was reset. - */ - -alt_timestamp_type alt_timestamp(void) -{ - - void* base = altera_avalon_timer_ts_base; - - if (!altera_avalon_timer_ts_freq) - { -#if (ALT_TIMESTAMP_COUNTER_SIZE == 64) - return 0xFFFFFFFFFFFFFFFFULL; -#else - return 0xFFFFFFFF; -#endif - } - else - { -#if (ALT_TIMESTAMP_COUNTER_SIZE == 64) - IOWR_ALTERA_AVALON_TIMER_SNAP_0 (base, 0); - alt_timestamp_type snap_0 = IORD_ALTERA_AVALON_TIMER_SNAP_0(base) & ALTERA_AVALON_TIMER_SNAP_0_MSK; - alt_timestamp_type snap_1 = IORD_ALTERA_AVALON_TIMER_SNAP_1(base) & ALTERA_AVALON_TIMER_SNAP_1_MSK; - alt_timestamp_type snap_2 = IORD_ALTERA_AVALON_TIMER_SNAP_2(base) & ALTERA_AVALON_TIMER_SNAP_2_MSK; - alt_timestamp_type snap_3 = IORD_ALTERA_AVALON_TIMER_SNAP_3(base) & ALTERA_AVALON_TIMER_SNAP_3_MSK; - - return (0xFFFFFFFFFFFFFFFFULL - ( (snap_3 << 48) | (snap_2 << 32) | (snap_1 << 16) | (snap_0) )); -#else - IOWR_ALTERA_AVALON_TIMER_SNAPL (base, 0); - alt_timestamp_type lower = IORD_ALTERA_AVALON_TIMER_SNAPL(base) & ALTERA_AVALON_TIMER_SNAPL_MSK; - alt_timestamp_type upper = IORD_ALTERA_AVALON_TIMER_SNAPH(base) & ALTERA_AVALON_TIMER_SNAPH_MSK; - - return (0xFFFFFFFF - ((upper << 16) | lower)); -#endif - } -} - -/* - * Return the number of timestamp ticks per second. This will be 0 if no - * timestamp device has been registered. - */ - -alt_u32 alt_timestamp_freq(void) -{ - return altera_avalon_timer_ts_freq; -} - -#endif /* timestamp available */ diff --git a/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/altera_avalon_timer_vars.c b/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/altera_avalon_timer_vars.c deleted file mode 100644 index de6f3ba37e..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_timer/HAL/src/altera_avalon_timer_vars.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -#include - -#include "altera_avalon_timer.h" -#include "alt_types.h" - -/* - * Variables used to store the timestamp parameters. These are initialised - * from alt_sys_init() using the ALTERA_AVALON_TIMER_INIT macro - * defined in altera_avalon_timer.h. - */ - -void* altera_avalon_timer_ts_base = (void*) 0; -alt_u32 altera_avalon_timer_ts_freq = 0; diff --git a/ext/hal/altera/drivers/altera_avalon_timer/inc/altera_avalon_timer_regs.h b/ext/hal/altera/drivers/altera_avalon_timer/inc/altera_avalon_timer_regs.h deleted file mode 100644 index 96e6a804b7..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_timer/inc/altera_avalon_timer_regs.h +++ /dev/null @@ -1,200 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALTERA_AVALON_TIMER_REGS_H__ -#define __ALTERA_AVALON_TIMER_REGS_H__ - -#include - -/* STATUS register */ -#define ALTERA_AVALON_TIMER_STATUS_REG 0 -#define IOADDR_ALTERA_AVALON_TIMER_STATUS(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_STATUS_REG) -#define IORD_ALTERA_AVALON_TIMER_STATUS(base) \ - IORD(base, ALTERA_AVALON_TIMER_STATUS_REG) -#define IOWR_ALTERA_AVALON_TIMER_STATUS(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_STATUS_REG, data) -#define ALTERA_AVALON_TIMER_STATUS_TO_MSK (0x1) -#define ALTERA_AVALON_TIMER_STATUS_TO_OFST (0) -#define ALTERA_AVALON_TIMER_STATUS_RUN_MSK (0x2) -#define ALTERA_AVALON_TIMER_STATUS_RUN_OFST (1) - -/* CONTROL register */ -#define ALTERA_AVALON_TIMER_CONTROL_REG 1 -#define IOADDR_ALTERA_AVALON_TIMER_CONTROL(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_CONTROL_REG) -#define IORD_ALTERA_AVALON_TIMER_CONTROL(base) \ - IORD(base, ALTERA_AVALON_TIMER_CONTROL_REG) -#define IOWR_ALTERA_AVALON_TIMER_CONTROL(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_CONTROL_REG, data) -#define ALTERA_AVALON_TIMER_CONTROL_ITO_MSK (0x1) -#define ALTERA_AVALON_TIMER_CONTROL_ITO_OFST (0) -#define ALTERA_AVALON_TIMER_CONTROL_CONT_MSK (0x2) -#define ALTERA_AVALON_TIMER_CONTROL_CONT_OFST (1) -#define ALTERA_AVALON_TIMER_CONTROL_START_MSK (0x4) -#define ALTERA_AVALON_TIMER_CONTROL_START_OFST (2) -#define ALTERA_AVALON_TIMER_CONTROL_STOP_MSK (0x8) -#define ALTERA_AVALON_TIMER_CONTROL_STOP_OFST (3) - -/* Period and SnapShot Register for COUNTER_SIZE = 32 */ -/*----------------------------------------------------*/ -/* PERIODL register */ -#define ALTERA_AVALON_TIMER_PERIODL_REG 2 -#define IOADDR_ALTERA_AVALON_TIMER_PERIODL(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_PERIODL_REG) -#define IORD_ALTERA_AVALON_TIMER_PERIODL(base) \ - IORD(base, ALTERA_AVALON_TIMER_PERIODL_REG) -#define IOWR_ALTERA_AVALON_TIMER_PERIODL(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_PERIODL_REG, data) -#define ALTERA_AVALON_TIMER_PERIODL_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_PERIODL_OFST (0) - -/* PERIODH register */ -#define ALTERA_AVALON_TIMER_PERIODH_REG 3 -#define IOADDR_ALTERA_AVALON_TIMER_PERIODH(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_PERIODH_REG) -#define IORD_ALTERA_AVALON_TIMER_PERIODH(base) \ - IORD(base, ALTERA_AVALON_TIMER_PERIODH_REG) -#define IOWR_ALTERA_AVALON_TIMER_PERIODH(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_PERIODH_REG, data) -#define ALTERA_AVALON_TIMER_PERIODH_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_PERIODH_OFST (0) - -/* SNAPL register */ -#define ALTERA_AVALON_TIMER_SNAPL_REG 4 -#define IOADDR_ALTERA_AVALON_TIMER_SNAPL(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_SNAPL_REG) -#define IORD_ALTERA_AVALON_TIMER_SNAPL(base) \ - IORD(base, ALTERA_AVALON_TIMER_SNAPL_REG) -#define IOWR_ALTERA_AVALON_TIMER_SNAPL(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_SNAPL_REG, data) -#define ALTERA_AVALON_TIMER_SNAPL_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_SNAPL_OFST (0) - -/* SNAPH register */ -#define ALTERA_AVALON_TIMER_SNAPH_REG 5 -#define IOADDR_ALTERA_AVALON_TIMER_SNAPH(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_SNAPH_REG) -#define IORD_ALTERA_AVALON_TIMER_SNAPH(base) \ - IORD(base, ALTERA_AVALON_TIMER_SNAPH_REG) -#define IOWR_ALTERA_AVALON_TIMER_SNAPH(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_SNAPH_REG, data) -#define ALTERA_AVALON_TIMER_SNAPH_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_SNAPH_OFST (0) - -/* Period and SnapShot Register for COUNTER_SIZE = 64 */ -/*----------------------------------------------------*/ -/* PERIOD_0 register */ -#define ALTERA_AVALON_TIMER_PERIOD_0_REG 2 -#define IOADDR_ALTERA_AVALON_TIMER_PERIOD_0(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_PERIOD_0_REG) -#define IORD_ALTERA_AVALON_TIMER_PERIOD_0(base) \ - IORD(base, ALTERA_AVALON_TIMER_PERIOD_0_REG) -#define IOWR_ALTERA_AVALON_TIMER_PERIOD_0(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_PERIOD_0_REG, data) -#define ALTERA_AVALON_TIMER_PERIOD_0_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_PERIOD_0_OFST (0) - -/* PERIOD_1 register */ -#define ALTERA_AVALON_TIMER_PERIOD_1_REG 3 -#define IOADDR_ALTERA_AVALON_TIMER_PERIOD_1(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_PERIOD_1_REG) -#define IORD_ALTERA_AVALON_TIMER_PERIOD_1(base) \ - IORD(base, ALTERA_AVALON_TIMER_PERIOD_1_REG) -#define IOWR_ALTERA_AVALON_TIMER_PERIOD_1(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_PERIOD_1_REG, data) -#define ALTERA_AVALON_TIMER_PERIOD_1_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_PERIOD_1_OFST (0) - -/* PERIOD_2 register */ -#define ALTERA_AVALON_TIMER_PERIOD_2_REG 4 -#define IOADDR_ALTERA_AVALON_TIMER_PERIOD_2(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_PERIOD_2_REG) -#define IORD_ALTERA_AVALON_TIMER_PERIOD_2(base) \ - IORD(base, ALTERA_AVALON_TIMER_PERIOD_2_REG) -#define IOWR_ALTERA_AVALON_TIMER_PERIOD_2(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_PERIOD_2_REG, data) -#define ALTERA_AVALON_TIMER_PERIOD_2_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_PERIOD_2_OFST (0) - -/* PERIOD_3 register */ -#define ALTERA_AVALON_TIMER_PERIOD_3_REG 5 -#define IOADDR_ALTERA_AVALON_TIMER_PERIOD_3(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_PERIOD_3_REG) -#define IORD_ALTERA_AVALON_TIMER_PERIOD_3(base) \ - IORD(base, ALTERA_AVALON_TIMER_PERIOD_3_REG) -#define IOWR_ALTERA_AVALON_TIMER_PERIOD_3(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_PERIOD_3_REG, data) -#define ALTERA_AVALON_TIMER_PERIOD_3_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_PERIOD_3_OFST (0) - -/* SNAP_0 register */ -#define ALTERA_AVALON_TIMER_SNAP_0_REG 6 -#define IOADDR_ALTERA_AVALON_TIMER_SNAP_0(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_SNAP_0_REG) -#define IORD_ALTERA_AVALON_TIMER_SNAP_0(base) \ - IORD(base, ALTERA_AVALON_TIMER_SNAP_0_REG) -#define IOWR_ALTERA_AVALON_TIMER_SNAP_0(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_SNAP_0_REG, data) -#define ALTERA_AVALON_TIMER_SNAP_0_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_SNAP_0_OFST (0) - -/* SNAP_1 register */ -#define ALTERA_AVALON_TIMER_SNAP_1_REG 7 -#define IOADDR_ALTERA_AVALON_TIMER_SNAP_1(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_SNAP_1_REG) -#define IORD_ALTERA_AVALON_TIMER_SNAP_1(base) \ - IORD(base, ALTERA_AVALON_TIMER_SNAP_1_REG) -#define IOWR_ALTERA_AVALON_TIMER_SNAP_1(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_SNAP_1_REG, data) -#define ALTERA_AVALON_TIMER_SNAP_1_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_SNAP_1_OFST (0) - -/* SNAP_2 register */ -#define ALTERA_AVALON_TIMER_SNAP_2_REG 8 -#define IOADDR_ALTERA_AVALON_TIMER_SNAP_2(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_SNAP_2_REG) -#define IORD_ALTERA_AVALON_TIMER_SNAP_2(base) \ - IORD(base, ALTERA_AVALON_TIMER_SNAP_2_REG) -#define IOWR_ALTERA_AVALON_TIMER_SNAP_2(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_SNAP_2_REG, data) -#define ALTERA_AVALON_TIMER_SNAP_2_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_SNAP_2_OFST (0) - -/* SNAP_3 register */ -#define ALTERA_AVALON_TIMER_SNAP_3_REG 9 -#define IOADDR_ALTERA_AVALON_TIMER_SNAP_3(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_TIMER_SNAP_3_REG) -#define IORD_ALTERA_AVALON_TIMER_SNAP_3(base) \ - IORD(base, ALTERA_AVALON_TIMER_SNAP_3_REG) -#define IOWR_ALTERA_AVALON_TIMER_SNAP_3(base, data) \ - IOWR(base, ALTERA_AVALON_TIMER_SNAP_3_REG, data) -#define ALTERA_AVALON_TIMER_SNAP_3_MSK (0xFFFF) -#define ALTERA_AVALON_TIMER_SNAP_3_OFST (0) - -#endif /* __ALTERA_AVALON_TIMER_REGS_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_uart/HAL/inc/altera_avalon_uart.h b/ext/hal/altera/drivers/altera_avalon_uart/HAL/inc/altera_avalon_uart.h deleted file mode 100644 index d08b78eb77..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/HAL/inc/altera_avalon_uart.h +++ /dev/null @@ -1,317 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALT_AVALON_UART_H__ -#define __ALT_AVALON_UART_H__ - -#include -#include - -#include "sys/alt_warning.h" - -#include "os/alt_sem.h" -#include "os/alt_flag.h" -#include "alt_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#if defined(ALT_USE_SMALL_DRIVERS) || defined(ALTERA_AVALON_UART_SMALL) - -/* - *********************************************************************** - *********************** SMALL DRIVER ********************************** - *********************************************************************** - */ - -/* - * State structure definition. Each instance of the driver uses one - * of these structures to hold its associated state. - */ - -typedef struct altera_avalon_uart_state_s -{ - unsigned int base; -} altera_avalon_uart_state; - -/* - * The macro ALTERA_AVALON_UART_STATE_INSTANCE is used by the - * auto-generated file alt_sys_init.c to create an instance of this - * device driver state. - */ - -#define ALTERA_AVALON_UART_STATE_INSTANCE(name, state) \ - altera_avalon_uart_state state = \ - { \ - name##_BASE \ - } - -/* - * The macro ALTERA_AVALON_UART_STATE_INIT is used by the auto-generated file - * alt_sys_init.c to initialize an instance of the device driver state. - */ - -#define ALTERA_AVALON_UART_STATE_INIT(name, state) - -#else /* fast driver */ - -/* - ********************************************************************** - *********************** FAST DRIVER ********************************** - ********************************************************************** - */ - -/* - * ALT_AVALON_UART_READ_RDY and ALT_AVALON_UART_WRITE_RDY are the bitmasks - * that define uC/OS-II event flags that are releated to this device. - * - * ALT_AVALON_UART_READY_RDY indicates that there is read data in the buffer - * ready to be processed. ALT_UART_WRITE_RDY indicates that the transmitter is - * ready for more data. - */ - -#define ALT_UART_READ_RDY 0x1 -#define ALT_UART_WRITE_RDY 0x2 - -/* - * ALT_AVALON_UART_BUF_LEN is the length of the circular buffers used to hold - * pending transmit and receive data. This value must be a power of two. - */ - -#define ALT_AVALON_UART_BUF_LEN (64) - -/* - * ALT_AVALON_UART_BUF_MSK is used as an internal convenience for detecting - * the end of the arrays used to implement the transmit and receive buffers. - */ - -#define ALT_AVALON_UART_BUF_MSK (ALT_AVALON_UART_BUF_LEN - 1) - -/* - * This is somewhat of an ugly hack, but we need some mechanism for - * representing the non-standard 9 bit mode provided by this UART. In this - * case we abscond with the 5 bit mode setting. The value CS5 is defined in - * termios.h. - */ - -#define CS9 CS5 - -/* - * The value ALT_AVALON_UART_FB is a value set in the devices flag field to - * indicate that the device has a fixed baud rate; i.e. if this flag is set - * software can not control the baud rate of the device. - */ - -#define ALT_AVALON_UART_FB 0x1 - -/* - * The value ALT_AVALON_UART_FC is a value set in the device flag field to - * indicate the the device is using flow control, i.e. the driver must - * throttle on transmit if the nCTS pin is low. - */ - -#define ALT_AVALON_UART_FC 0x2 - -/* - * The altera_avalon_uart_state structure is used to hold device specific data. - * This includes the transmit and receive buffers. - * - * An instance of this structure is created in the auto-generated - * alt_sys_init.c file for each UART listed in the systems PTF file. This is - * done using the ALTERA_AVALON_UART_STATE_INSTANCE macro given below. - */ - -typedef struct altera_avalon_uart_state_s -{ - void* base; /* The base address of the device */ - alt_u32 ctrl; /* Shadow value of the control register */ - volatile alt_u32 rx_start; /* Start of the pending receive data */ - volatile alt_u32 rx_end; /* End of the pending receive data */ - volatile alt_u32 tx_start; /* Start of the pending transmit data */ - volatile alt_u32 tx_end; /* End of the pending transmit data */ -#ifdef ALTERA_AVALON_UART_USE_IOCTL - struct termios termios; /* Current device configuration */ - alt_u32 freq; /* Current baud rate */ -#endif - alt_u32 flags; /* Configuation flags */ - ALT_FLAG_GRP (events) /* Event flags used for - * foreground/background in mult-threaded - * mode */ - ALT_SEM (read_lock) /* Semaphore used to control access to the - * read buffer in multi-threaded mode */ - ALT_SEM (write_lock) /* Semaphore used to control access to the - * write buffer in multi-threaded mode */ - volatile alt_u8 rx_buf[ALT_AVALON_UART_BUF_LEN]; /* The receive buffer */ - volatile alt_u8 tx_buf[ALT_AVALON_UART_BUF_LEN]; /* The transmit buffer */ -} altera_avalon_uart_state; - -/* - * Conditionally define the data structures used to process ioctl requests. - * The following macros are defined for use in creating a device instance: - * - * ALTERA_AVALON_UART_TERMIOS - Initialise the termios structure used to - * describe the UART configuration. - * ALTERA_AVALON_UART_FREQ - Initialise the 'freq' field of the device - * structure, if the field exists. - * ALTERA_AVALON_UART_IOCTL - Initialise the 'ioctl' field of the device - * callback structure, if ioctls are enabled. - */ - -#ifdef ALTERA_AVALON_UART_USE_IOCTL - -#define ALTERA_AVALON_UART_TERMIOS(stop_bits, \ - parity, \ - odd_parity, \ - data_bits, \ - ctsrts, \ - baud) \ -{ \ - 0, \ - 0, \ - ((stop_bits == 2) ? CSTOPB: 0) | \ - ((parity) ? PARENB: 0) | \ - ((odd_parity) ? PAODD: 0) | \ - ((data_bits == 7) ? CS7: (data_bits == 9) ? CS9: CS8) | \ - ((ctsrts) ? CRTSCTS : 0), \ - 0, \ - 0, \ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ - baud, \ - baud \ -}, -#define ALTERA_AVALON_UART_FREQ(name) name##_FREQ, - -#else /* !ALTERA_AVALON_UART_USE_IOCTL */ - -#define ALTERA_AVALON_UART_TERMIOS(stop_bits, \ - parity, \ - odd_parity, \ - data_bits, \ - ctsrts, \ - baud) -#define ALTERA_AVALON_UART_FREQ(name) - -#endif /* ALTERA_AVALON_UART_USE_IOCTL */ - -/* - * The macro ALTERA_AVALON_UART_INSTANCE is used by the auto-generated file - * alt_sys_init.c to create an instance of this device driver state. - */ - -#define ALTERA_AVALON_UART_STATE_INSTANCE(name, state) \ - altera_avalon_uart_state state = \ - { \ - (void*) name##_BASE, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - ALTERA_AVALON_UART_TERMIOS(name##_STOP_BITS, \ - (name##_PARITY == 'N'), \ - (name##_PARITY == 'O'), \ - name##_DATA_BITS, \ - name##_USE_CTS_RTS, \ - name##_BAUD) \ - ALTERA_AVALON_UART_FREQ(name) \ - (name##_FIXED_BAUD ? ALT_AVALON_UART_FB : 0) | \ - (name##_USE_CTS_RTS ? ALT_AVALON_UART_FC : 0) \ - } - -/* - * altera_avalon_uart_init() is called by the auto-generated function - * alt_sys_init() for each UART in the system. This is done using the - * ALTERA_AVALON_UART_INIT macro given below. - * - * This function is responsible for performing all the run time initilisation - * for a device instance, i.e. registering the interrupt handler, and - * regestering the device with the system. - */ -extern void altera_avalon_uart_init(altera_avalon_uart_state* sp, - alt_u32 irq_controller_id, alt_u32 irq); - -/* - * The macro ALTERA_AVALON_UART_STATE_INIT is used by the auto-generated file - * alt_sys_init.c to initialize an instance of the device driver state. - * - * This macro performs a sanity check to ensure that the interrupt has been - * connected for this device. If not, then an apropriate error message is - * generated at build time. - */ - -#define ALTERA_AVALON_UART_STATE_INIT(name, state) \ - if (name##_IRQ == ALT_IRQ_NOT_CONNECTED) \ - { \ - ALT_LINK_ERROR ("Error: Interrupt not connected for " #name ". " \ - "You have selected the interrupt driven version of " \ - "the ALTERA Avalon UART driver, but the interrupt is " \ - "not connected for this device. You can select a " \ - "polled mode driver by checking the 'small driver' " \ - "option in the HAL configuration window, or by " \ - "using the -DALTERA_AVALON_UART_SMALL preprocessor " \ - "flag."); \ - } \ - else \ - { \ - altera_avalon_uart_init(&state, name##_IRQ_INTERRUPT_CONTROLLER_ID, \ - name##_IRQ); \ - } - -#endif /* small driver */ - -/* - * Include in case non-direct version of driver required. - */ -#include "altera_avalon_uart_fd.h" - -/* - * Map alt_sys_init macros to direct or non-direct versions. - */ -#ifdef ALT_USE_DIRECT_DRIVERS - -#define ALTERA_AVALON_UART_INSTANCE(name, state) \ - ALTERA_AVALON_UART_STATE_INSTANCE(name, state) -#define ALTERA_AVALON_UART_INIT(name, state) \ - ALTERA_AVALON_UART_STATE_INIT(name, state) - -#else /* !ALT_USE_DIRECT_DRIVERS */ - -#define ALTERA_AVALON_UART_INSTANCE(name, dev) \ - ALTERA_AVALON_UART_DEV_INSTANCE(name, dev) -#define ALTERA_AVALON_UART_INIT(name, dev) \ - ALTERA_AVALON_UART_DEV_INIT(name, dev) - -#endif /* ALT_USE_DIRECT_DRIVERS */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_AVALON_UART_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_uart/HAL/inc/altera_avalon_uart_fd.h b/ext/hal/altera/drivers/altera_avalon_uart/HAL/inc/altera_avalon_uart_fd.h deleted file mode 100644 index 40aa06183a..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/HAL/inc/altera_avalon_uart_fd.h +++ /dev/null @@ -1,141 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2007 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALT_AVALON_UART_FD_H__ -#define __ALT_AVALON_UART_FD_H__ - -#include "sys/alt_dev.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * Externally referenced routines - */ -extern int altera_avalon_uart_read_fd (alt_fd* fd, char* ptr, int len); -extern int altera_avalon_uart_write_fd (alt_fd* fd, const char* ptr, - int len); - -/* - * Device structure definition. This is needed by alt_sys_init in order to - * reserve memory for the device instance. - */ -typedef struct altera_avalon_uart_dev_s -{ - alt_dev dev; - altera_avalon_uart_state state; -} altera_avalon_uart_dev; - -#if defined(ALT_USE_SMALL_DRIVERS) || defined(ALTERA_AVALON_UART_SMALL) - -/* - * Macros used by alt_sys_init when the ALT file descriptor facility is used. - */ - -#define ALTERA_AVALON_UART_DEV_INSTANCE(name, d) \ - static altera_avalon_uart_dev d = \ - { \ - { \ - ALT_LLIST_ENTRY, \ - name##_NAME, \ - NULL, /* open */ \ - NULL, /* close */ \ - altera_avalon_uart_read_fd, \ - altera_avalon_uart_write_fd, \ - NULL, /* lseek */ \ - NULL, /* fstat */ \ - NULL, /* ioctl */ \ - }, \ - { \ - name##_BASE, \ - } \ - } - -#define ALTERA_AVALON_UART_DEV_INIT(name, d) alt_dev_reg (&d.dev) - -#else /* use fast version of the driver */ - -extern int altera_avalon_uart_ioctl_fd (alt_fd* fd, int req, void* arg); -extern int altera_avalon_uart_close_fd(alt_fd* fd); - -#ifdef ALTERA_AVALON_UART_USE_IOCTL -#define ALTERA_AVALON_UART_IOCTL_FD altera_avalon_uart_ioctl_fd -#else -#define ALTERA_AVALON_UART_IOCTL_FD NULL -#endif - -#define ALTERA_AVALON_UART_DEV_INSTANCE(name, d) \ - static altera_avalon_uart_dev d = \ - { \ - { \ - ALT_LLIST_ENTRY, \ - name##_NAME, \ - NULL, /* open */ \ - altera_avalon_uart_close_fd, \ - altera_avalon_uart_read_fd, \ - altera_avalon_uart_write_fd, \ - NULL, /* lseek */ \ - NULL, /* fstat */ \ - ALTERA_AVALON_UART_IOCTL_FD, \ - }, \ - { \ - (void*) name##_BASE, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - ALTERA_AVALON_UART_TERMIOS(name##_STOP_BITS, \ - (name##_PARITY == 'N'), \ - (name##_PARITY == 'O'), \ - name##_DATA_BITS, \ - name##_USE_CTS_RTS, \ - name##_BAUD) \ - ALTERA_AVALON_UART_FREQ(name) \ - (name##_FIXED_BAUD ? ALT_AVALON_UART_FB : 0) | \ - (name##_USE_CTS_RTS ? ALT_AVALON_UART_FC : 0) \ - } \ - } - -#define ALTERA_AVALON_UART_DEV_INIT(name, d) \ - { \ - ALTERA_AVALON_UART_STATE_INIT(name, d.state); \ - \ - /* make the device available to the system */ \ - alt_dev_reg(&d.dev); \ - } - -#endif /* fast driver */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_AVALON_UART_FD_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/CMakeLists.txt b/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/CMakeLists.txt deleted file mode 100644 index 5c3dc32d5c..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -zephyr_sources( - altera_avalon_uart_fd.c - altera_avalon_uart_init.c - altera_avalon_uart_ioctl.c - altera_avalon_uart_read.c - altera_avalon_uart_write.c - ) diff --git a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_fd.c b/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_fd.c deleted file mode 100644 index 26a05dd2c0..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_fd.c +++ /dev/null @@ -1,98 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2007 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include "alt_types.h" -#include "sys/alt_dev.h" -#include "altera_avalon_uart.h" - -extern int altera_avalon_uart_read(altera_avalon_uart_state* sp, - char* buffer, int space, int flags); -extern int altera_avalon_uart_write(altera_avalon_uart_state* sp, - const char* ptr, int count, int flags); -extern int altera_avalon_uart_ioctl(altera_avalon_uart_state* sp, - int req, void* arg); -extern int altera_avalon_uart_close(altera_avalon_uart_state* sp, int flags); - -/* ----------------------------------------------------------------------- */ -/* --------------------- WRAPPERS FOR ALT FD SUPPORT --------------------- */ -/* - * - */ - -int -altera_avalon_uart_read_fd(alt_fd* fd, char* buffer, int space) -{ - altera_avalon_uart_dev* dev = (altera_avalon_uart_dev*) fd->dev; - - return altera_avalon_uart_read(&dev->state, buffer, space, - fd->fd_flags); -} - -int -altera_avalon_uart_write_fd(alt_fd* fd, const char* buffer, int space) -{ - altera_avalon_uart_dev* dev = (altera_avalon_uart_dev*) fd->dev; - - return altera_avalon_uart_write(&dev->state, buffer, space, - fd->fd_flags); -} - -#if !defined(ALT_USE_SMALL_DRIVERS) && !defined(ALTERA_AVALON_UART_SMALL) - -/* - * Fast driver - */ - -/* - * To reduce the code footprint of this driver, the ioctl() function is not - * included by default. If you wish to use the ioctl features provided - * below, you can do so by adding the option : -DALTERA_AVALON_UART_USE_IOCTL - * to CPPFLAGS in the Makefile (or through the Eclipse IDE). - */ - -#ifdef ALTERA_AVALON_UART_USE_IOCTL - -int -altera_avalon_uart_ioctl_fd(alt_fd* fd, int req, void* arg) -{ - altera_avalon_uart_dev* dev = (altera_avalon_uart_dev*) fd->dev; - - return altera_avalon_uart_ioctl(&dev->state, req, arg); -} - -#endif /* ALTERA_AVALON_UART_USE_IOCTL */ - -int -altera_avalon_uart_close_fd(alt_fd* fd) -{ - altera_avalon_uart_dev* dev = (altera_avalon_uart_dev*) fd->dev; - - return altera_avalon_uart_close(&dev->state, fd->fd_flags); -} - -#endif /* fast driver */ diff --git a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_init.c b/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_init.c deleted file mode 100644 index 2b4600470c..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_init.c +++ /dev/null @@ -1,310 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include - -#include "sys/alt_dev.h" -#include "sys/alt_irq.h" -#include "sys/ioctl.h" -#include "sys/alt_errno.h" - -#include "altera_avalon_uart.h" -#include "altera_avalon_uart_regs.h" - -#if !defined(ALT_USE_SMALL_DRIVERS) && !defined(ALTERA_AVALON_UART_SMALL) - -/* ----------------------------------------------------------- */ -/* ------------------------- FAST DRIVER --------------------- */ -/* ----------------------------------------------------------- */ - -/* - * altera_avalon_uart_init() is called by the auto-generated function - * alt_sys_init() in order to initialize a particular instance of this device. - * It is responsible for configuring the device and associated software - * constructs. - */ - -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT -static void altera_avalon_uart_irq(void* context); -#else -static void altera_avalon_uart_irq(void* context, alt_u32 id); -#endif - -static void altera_avalon_uart_rxirq(altera_avalon_uart_state* sp, - alt_u32 status); -static void altera_avalon_uart_txirq(altera_avalon_uart_state* sp, - alt_u32 status); - -void -altera_avalon_uart_init(altera_avalon_uart_state* sp, - alt_u32 irq_controller_id, alt_u32 irq) -{ - void* base = sp->base; - int error; - - /* - * Initialise the read and write flags and the semaphores used to - * protect access to the circular buffers when running in a multi-threaded - * environment. - */ - error = ALT_FLAG_CREATE (&sp->events, 0) || - ALT_SEM_CREATE (&sp->read_lock, 1) || - ALT_SEM_CREATE (&sp->write_lock, 1); - - if (!error) - { - /* enable interrupts at the device */ - sp->ctrl = ALTERA_AVALON_UART_CONTROL_RTS_MSK | - ALTERA_AVALON_UART_CONTROL_RRDY_MSK | - ALTERA_AVALON_UART_CONTROL_DCTS_MSK; - - IOWR_ALTERA_AVALON_UART_CONTROL(base, sp->ctrl); - - /* register the interrupt handler */ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT - alt_ic_isr_register(irq_controller_id, irq, altera_avalon_uart_irq, sp, - 0x0); -#else - alt_irq_register (irq, sp, altera_avalon_uart_irq); -#endif - } -} - -/* - * altera_avalon_uart_irq() is the interrupt handler registered at - * configuration time for processing UART interrupts. It vectors - * interrupt requests to either altera_avalon_uart_rxirq() (for incoming - * data), or altera_avalon_uart_txirq() (for outgoing data). - */ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT -static void altera_avalon_uart_irq(void* context) -#else -static void altera_avalon_uart_irq(void* context, alt_u32 id) -#endif -{ - alt_u32 status; - - altera_avalon_uart_state* sp = (altera_avalon_uart_state*) context; - void* base = sp->base; - - /* - * Read the status register in order to determine the cause of the - * interrupt. - */ - - status = IORD_ALTERA_AVALON_UART_STATUS(base); - - /* Clear any error flags set at the device */ - IOWR_ALTERA_AVALON_UART_STATUS(base, 0); - - /* Dummy read to ensure IRQ is negated before ISR returns */ - IORD_ALTERA_AVALON_UART_STATUS(base); - - /* process a read irq */ - if (status & ALTERA_AVALON_UART_STATUS_RRDY_MSK) - { - altera_avalon_uart_rxirq(sp, status); - } - - /* process a write irq */ - if (status & (ALTERA_AVALON_UART_STATUS_TRDY_MSK | - ALTERA_AVALON_UART_STATUS_DCTS_MSK)) - { - altera_avalon_uart_txirq(sp, status); - } - - -} - -/* - * altera_avalon_uart_rxirq() is called by altera_avalon_uart_irq() to - * process a receive interrupt. It transfers the incoming character into - * the receive circular buffer, and sets the apropriate flags to indicate - * that there is data ready to be processed. - */ -static void -altera_avalon_uart_rxirq(altera_avalon_uart_state* sp, alt_u32 status) -{ - alt_u32 next; - - /* If there was an error, discard the data */ - - if (status & (ALTERA_AVALON_UART_STATUS_PE_MSK | - ALTERA_AVALON_UART_STATUS_FE_MSK)) - { - return; - } - - /* - * In a multi-threaded environment, set the read event flag to indicate - * that there is data ready. This is only done if the circular buffer was - * previously empty. - */ - - if (sp->rx_end == sp->rx_start) - { - ALT_FLAG_POST (sp->events, ALT_UART_READ_RDY, OS_FLAG_SET); - } - - /* Determine which slot to use next in the circular buffer */ - - next = (sp->rx_end + 1) & ALT_AVALON_UART_BUF_MSK; - - /* Transfer data from the device to the circular buffer */ - - sp->rx_buf[sp->rx_end] = IORD_ALTERA_AVALON_UART_RXDATA(sp->base); - - sp->rx_end = next; - - next = (sp->rx_end + 1) & ALT_AVALON_UART_BUF_MSK; - - /* - * If the cicular buffer was full, disable interrupts. Interrupts will be - * re-enabled when data is removed from the buffer. - */ - - if (next == sp->rx_start) - { - sp->ctrl &= ~ALTERA_AVALON_UART_CONTROL_RRDY_MSK; - IOWR_ALTERA_AVALON_UART_CONTROL(sp->base, sp->ctrl); - } -} - -/* - * altera_avalon_uart_txirq() is called by altera_avalon_uart_irq() to - * process a transmit interrupt. It transfers data from the transmit - * buffer to the device, and sets the apropriate flags to indicate that - * there is data ready to be processed. - */ -static void -altera_avalon_uart_txirq(altera_avalon_uart_state* sp, alt_u32 status) -{ - /* Transfer data if there is some ready to be transfered */ - - if (sp->tx_start != sp->tx_end) - { - /* - * If the device is using flow control (i.e. RTS/CTS), then the - * transmitter is required to throttle if CTS is high. - */ - - if (!(sp->flags & ALT_AVALON_UART_FC) || - (status & ALTERA_AVALON_UART_STATUS_CTS_MSK)) - { - - /* - * In a multi-threaded environment, set the write event flag to indicate - * that there is space in the circular buffer. This is only done if the - * buffer was previously empty. - */ - - if (sp->tx_start == ((sp->tx_end + 1) & ALT_AVALON_UART_BUF_MSK)) - { - ALT_FLAG_POST (sp->events, - ALT_UART_WRITE_RDY, - OS_FLAG_SET); - } - - /* Write the data to the device */ - - IOWR_ALTERA_AVALON_UART_TXDATA(sp->base, sp->tx_buf[sp->tx_start]); - - sp->tx_start = (++sp->tx_start) & ALT_AVALON_UART_BUF_MSK; - - /* - * In case the tranmit interrupt had previously been disabled by - * detecting a low value on CTS, it is reenabled here. - */ - - sp->ctrl |= ALTERA_AVALON_UART_CONTROL_TRDY_MSK; - } - else - { - /* - * CTS is low and we are using flow control, so disable the transmit - * interrupt while we wait for CTS to go high again. This will be - * detected using the DCTS interrupt. - * - * There is a race condition here. "status" may indicate that - * CTS is low, but it actually went high before DCTS was cleared on - * the last write to the status register. To avoid this resulting in - * deadlock, it's necessary to re-check the status register here - * before throttling. - */ - - status = IORD_ALTERA_AVALON_UART_STATUS(sp->base); - - if (!(status & ALTERA_AVALON_UART_STATUS_CTS_MSK)) - { - sp->ctrl &= ~ALTERA_AVALON_UART_CONTROL_TRDY_MSK; - } - } - } - - /* - * If the circular buffer is empty, disable the interrupt. This will be - * re-enabled when new data is placed in the buffer. - */ - - if (sp->tx_start == sp->tx_end) - { - sp->ctrl &= ~(ALTERA_AVALON_UART_CONTROL_TRDY_MSK | - ALTERA_AVALON_UART_CONTROL_DCTS_MSK); - } - - IOWR_ALTERA_AVALON_UART_CONTROL(sp->base, sp->ctrl); -} - -/* - * The close() routine is implemented to drain the UART transmit buffer - * when not in "small" mode. This routine will wait for transimt data to be - * emptied unless the driver flags have been set to non-blocking mode. - * This routine should be called indirectly (i.e. though the C library - * close() routine) so that the file descriptor associated with the relevant - * stream (i.e. stdout) can be closed as well. This routine does not manage - * file descriptors. - * - * The close routine is not implemented for the small driver; instead it will - * map to null. This is because the small driver simply waits while characters - * are transmitted; there is no interrupt-serviced buffer to empty - */ -int altera_avalon_uart_close(altera_avalon_uart_state* sp, int flags) -{ - /* - * Wait for all transmit data to be emptied by the UART ISR. - */ - while (sp->tx_start != sp->tx_end) { - if (flags & O_NONBLOCK) { - return -EWOULDBLOCK; - } - } - - return 0; -} - -#endif /* fast driver */ diff --git a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_ioctl.c b/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_ioctl.c deleted file mode 100644 index 69a97425ed..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_ioctl.c +++ /dev/null @@ -1,151 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include -#include - -#include "sys/alt_irq.h" -#include "sys/ioctl.h" -#include "sys/alt_errno.h" - -#include "altera_avalon_uart_regs.h" -#include "altera_avalon_uart.h" - - -#if !defined(ALT_USE_SMALL_DRIVERS) && !defined(ALTERA_AVALON_UART_SMALL) - -/* ----------------------------------------------------------- */ -/* ------------------------- FAST DRIVER --------------------- */ -/* ----------------------------------------------------------- */ - -/* - * To reduce the code footprint of this driver, the ioctl() function is not - * included by default. If you wish to use the ioctl features provided - * below, you can do so by adding the option : -DALTERA_AVALON_UART_USE_IOCTL - * to CPPFLAGS in the Makefile (or through the Eclipse IDE). - */ - -#ifdef ALTERA_AVALON_UART_USE_IOCTL - -/* - * altera_avalon_uart_ioctl() is called by the system ioctl() function to handle - * ioctl requests for the UART. The only ioctl requests supported are TIOCMGET - * and TIOCMSET. - * - * TIOCMGET returns a termios structure that describes the current device - * configuration. - * - * TIOCMSET sets the device (if possible) to match the requested configuration. - * The requested configuration is described using a termios structure passed - * through the input argument "arg". - */ - -static int altera_avalon_uart_tiocmget(altera_avalon_uart_state* sp, - struct termios* term); -static int altera_avalon_uart_tiocmset(altera_avalon_uart_state* sp, - struct termios* term); - -int -altera_avalon_uart_ioctl(altera_avalon_uart_state* sp, int req, void* arg) -{ - int rc = -ENOTTY; - - switch (req) - { - case TIOCMGET: - rc = altera_avalon_uart_tiocmget(sp, (struct termios*) arg); - break; - case TIOCMSET: - rc = altera_avalon_uart_tiocmset(sp, (struct termios*) arg); - break; - default: - break; - } - return rc; -} - -/* - * altera_avalon_uart_tiocmget() is used by altera_avalon_uart_ioctl() to fill - * in the input termios structure with the current device configuration. - * - * See termios.h for further details on the contents of the termios structure. - */ - -static int -altera_avalon_uart_tiocmget(altera_avalon_uart_state* sp, - struct termios* term) -{ - memcpy (term, &sp->termios, sizeof (struct termios)); - return 0; -} - -/* - * altera_avalon_uart_tiocmset() is used by altera_avalon_uart_ioctl() to - * configure the device according to the settings in the input termios - * structure. In practice the only configuration that can be changed is the - * baud rate, and then only if the hardware is configured to have a writable - * baud register. - */ - -static int -altera_avalon_uart_tiocmset(altera_avalon_uart_state* sp, - struct termios* term) -{ - speed_t speed; - - speed = sp->termios.c_ispeed; - - /* Update the settings if the hardware supports it */ - - if (!(sp->flags & ALT_AVALON_UART_FB)) - { - sp->termios.c_ispeed = sp->termios.c_ospeed = term->c_ispeed; - } - /* - * If the request was for an unsupported setting, return an error. - */ - - if (memcmp(term, &sp->termios, sizeof (struct termios))) - { - sp->termios.c_ispeed = sp->termios.c_ospeed = speed; - return -EIO; - } - - /* - * Otherwise, update the hardware. - */ - - IOWR_ALTERA_AVALON_UART_DIVISOR(sp->base, - ((sp->freq/sp->termios.c_ispeed) - 1)); - - return 0; -} - -#endif /* ALTERA_AVALON_UART_USE_IOCTL */ - -#endif /* fast driver */ diff --git a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_read.c b/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_read.c deleted file mode 100644 index 692966f9da..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_read.c +++ /dev/null @@ -1,238 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include - -#include "sys/alt_irq.h" -#include "sys/ioctl.h" -#include "sys/alt_errno.h" - -#include "altera_avalon_uart.h" -#include "altera_avalon_uart_regs.h" - -#if defined(ALT_USE_SMALL_DRIVERS) || defined(ALTERA_AVALON_UART_SMALL) - -/* ----------------------------------------------------------- */ -/* ----------------------- SMALL DRIVER ---------------------- */ -/* ----------------------------------------------------------- */ - -/* - * altera_avalon_uart_read() is called by the system read() function in order to - * read a block of data from the UART. "len" is the maximum length of the data - * to read, and "ptr" indicates the destination address. "fd" is the file - * descriptor for the device to be read from. - * - * Permission checks are made before the call to altera_avalon_uart_read(), so - * we know that the file descriptor has been opened with the correct permissions - * for this operation. - * - * The return value is the number of bytes actually read. - * - * This implementation polls the device waiting for characters. At most it can - * only return one character, regardless of how many are requested. If the - * device is being accessed in non-blocking mode then it is possible for this - * function to return without reading any characters. In this case errno is - * set to EWOULDBLOCK. - */ - -int -altera_avalon_uart_read(altera_avalon_uart_state* sp, char* ptr, int len, - int flags) -{ - int block; - unsigned int status; - - block = !(flags & O_NONBLOCK); - - do - { - status = IORD_ALTERA_AVALON_UART_STATUS(sp->base); - - /* clear any error flags */ - - IOWR_ALTERA_AVALON_UART_STATUS(sp->base, 0); - - if (status & ALTERA_AVALON_UART_CONTROL_RRDY_MSK) - { - ptr[0] = IORD_ALTERA_AVALON_UART_RXDATA(sp->base); - - if (!(status & (ALTERA_AVALON_UART_STATUS_PE_MSK | - ALTERA_AVALON_UART_STATUS_FE_MSK))) - { - return 1; - } - } - } - while (block); - - ALT_ERRNO = EWOULDBLOCK; - - return 0; -} - -#else - -/* ----------------------------------------------------------- */ -/* ----------------------- FAST DRIVER ----------------------- */ -/* ----------------------------------------------------------- */ - -/* - * altera_avalon_uart_read() is called by the system read() function in order to - * read a block of data from the UART. "len" is the maximum length of the data - * to read, and "ptr" indicates the destination address. "sp" is the state - * pointer for the device to be read from. - * - * Permission checks are made before the call to altera_avalon_uart_read(), so - * we know that the file descriptor has been opened with the correct permissions - * for this operation. - * - * The return value is the number of bytes actually read. - * - * This function does not communicate with the device directly. Instead data is - * transfered from a circular buffer. The interrupt handler is then responsible - * for copying data from the device into this buffer. - */ - -int -altera_avalon_uart_read(altera_avalon_uart_state* sp, char* ptr, int len, - int flags) -{ - alt_irq_context context; - int block; - alt_u8 read_would_block = 0; - int count = 0; - - /* - * Construct a flag to indicate whether the device is being accessed in - * blocking or non-blocking mode. - */ - - block = !(flags & O_NONBLOCK); - - /* - * When running in a multi threaded environment, obtain the "read_lock" - * semaphore. This ensures that reading from the device is thread-safe. - */ - - ALT_SEM_PEND (sp->read_lock, 0); - - /* - * Loop, copying data from the circular buffer to the destination address - * supplied in "ptr". This loop is terminated when the required number of - * bytes have been read. If the circular buffer is empty, and no data has - * been read, then the loop will block (when in blocking mode). - * - * If the circular buffer is empty, and some data has already been - * transferred, or the device is being accessed in non-blocking mode, then - * the loop terminates without necessarily reading all the requested data. - */ - - do - { - /* - * Read the required amount of data, until the circular buffer runs - * empty - */ - - while ((count < len) && (sp->rx_start != sp->rx_end)) - { - count++; - *ptr++ = sp->rx_buf[sp->rx_start]; - - sp->rx_start = (sp->rx_start+1) & ALT_AVALON_UART_BUF_MSK; - } - - /* - * If no data has been transferred, the circular buffer is empty, and - * this is not a non-blocking access, block waiting for data to arrive. - */ - - if (!count && (sp->rx_start == sp->rx_end)) - { - if (!block) - { - /* Set errno to indicate the reason we're not returning any data */ - - ALT_ERRNO = EWOULDBLOCK; - read_would_block = 1; - break; - } - else - { - /* Block waiting for some data to arrive */ - - /* First, ensure read interrupts are enabled to avoid deadlock */ - - context = alt_irq_disable_all (); - sp->ctrl |= ALTERA_AVALON_UART_CONTROL_RRDY_MSK; - IOWR_ALTERA_AVALON_UART_CONTROL(sp->base, sp->ctrl); - alt_irq_enable_all (context); - - /* - * When running in a multi-threaded mode, we pend on the read event - * flag set in the interrupt service routine. This avoids wasting CPU - * cycles waiting in this thread, when we could be doing something more - * profitable elsewhere. - */ - - ALT_FLAG_PEND (sp->events, - ALT_UART_READ_RDY, - OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME, - 0); - } - } - } - while (!count && len); - - /* - * Now that access to the circular buffer is complete, release the read - * semaphore so that other threads can access the buffer. - */ - - ALT_SEM_POST (sp->read_lock); - - /* - * Ensure that interrupts are enabled, so that the circular buffer can - * re-fill. - */ - - context = alt_irq_disable_all (); - sp->ctrl |= ALTERA_AVALON_UART_CONTROL_RRDY_MSK; - IOWR_ALTERA_AVALON_UART_CONTROL(sp->base, sp->ctrl); - alt_irq_enable_all (context); - - /* Return the number of bytes read */ - if(read_would_block) { - return -EWOULDBLOCK; - } - else { - return count; - } -} - -#endif /* fast driver */ diff --git a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_write.c b/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_write.c deleted file mode 100644 index 26b3c4e7ec..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/HAL/src/altera_avalon_uart_write.c +++ /dev/null @@ -1,230 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include - -#include "sys/alt_dev.h" -#include "sys/alt_irq.h" -#include "sys/ioctl.h" -#include "sys/alt_errno.h" - -#include "altera_avalon_uart_regs.h" -#include "altera_avalon_uart.h" - -#if defined(ALT_USE_SMALL_DRIVERS) || defined(ALTERA_AVALON_UART_SMALL) - -/* ----------------------------------------------------------- */ -/* ------------------------ SMALL DRIVER --------------------- */ -/* ----------------------------------------------------------- */ - -/* - * altera_avalon_uart_write() is called by the system write() function in - * order to write a block of data to the UART. - * "len" is the length of the data to write, - * and "ptr" indicates the source address. "fd" is the file descriptor for the - * device to be read from. - * - * Permission checks are made before the call to altera_avalon_uart_write(), so - * we know that the file descriptor has been opened with the correct permissions - * for this operation. - * - * The return value is the number of bytes actually written. - * - * This function will block on the devices transmit register, until all - * characters have been transmitted. This is unless the device is being - * accessed in non-blocking mode. In this case this function will return as - * soon as the device reports that it is not ready to transmit. - * - * Since this is the small footprint version of the UART driver, the value of - * CTS is ignored. - */ - -int -altera_avalon_uart_write(altera_avalon_uart_state* sp, const char* ptr, int len, - int flags) -{ - int block; - unsigned int status; - int count; - - block = !(flags & O_NONBLOCK); - count = len; - - do - { - status = IORD_ALTERA_AVALON_UART_STATUS(sp->base); - - if (status & ALTERA_AVALON_UART_STATUS_TRDY_MSK) - { - IOWR_ALTERA_AVALON_UART_TXDATA(sp->base, *ptr++); - count--; - } - } - while (block && count); - - if (count) - { - ALT_ERRNO = EWOULDBLOCK; - } - - return (len - count); -} - -#else /* Using the "fast" version of the driver */ - -/* ----------------------------------------------------------- */ -/* ------------------------- FAST DRIVER --------------------- */ -/* ----------------------------------------------------------- */ - -/* - * altera_avalon_uart_write() is called by the system write() function in order - * to write a block of data to the UART. "len" is the length of the data to - * write, and "ptr" indicates the source address. "sp" is the state pointer - * for the device to be written to. - * - * Permission checks are made before the call to altera_avalon_uart_write(), so - * we know that the file descriptor has been opened with the correct permissions - * for this operation. - * - * The return value is the number of bytes actually written. - * - * This function does not communicate with the device directly. Instead data is - * transfered to a circular buffer. The interrupt handler is then responsible - * for copying data from this buffer into the device. - */ - -int -altera_avalon_uart_write(altera_avalon_uart_state* sp, const char* ptr, int len, - int flags) -{ - alt_irq_context context; - int no_block; - alt_u32 next; - int count = len; - - /* - * Construct a flag to indicate whether the device is being accessed in - * blocking or non-blocking mode. - */ - - no_block = (flags & O_NONBLOCK); - - /* - * When running in a multi threaded environment, obtain the "write_lock" - * semaphore. This ensures that writing to the device is thread-safe. - */ - - ALT_SEM_PEND (sp->write_lock, 0); - - /* - * Loop transferring data from the input buffer to the transmit circular - * buffer. The loop is terminated once all the data has been transferred, - * or, (if in non-blocking mode) the buffer becomes full. - */ - - while (count) - { - /* Determine the next slot in the buffer to access */ - - next = (sp->tx_end + 1) & ALT_AVALON_UART_BUF_MSK; - - /* block waiting for space if necessary */ - - if (next == sp->tx_start) - { - if (no_block) - { - /* Set errno to indicate why this function returned early */ - - ALT_ERRNO = EWOULDBLOCK; - break; - } - else - { - /* Block waiting for space in the circular buffer */ - - /* First, ensure transmit interrupts are enabled to avoid deadlock */ - - context = alt_irq_disable_all (); - sp->ctrl |= (ALTERA_AVALON_UART_CONTROL_TRDY_MSK | - ALTERA_AVALON_UART_CONTROL_DCTS_MSK); - IOWR_ALTERA_AVALON_UART_CONTROL(sp->base, sp->ctrl); - alt_irq_enable_all (context); - - /* wait for space to come free */ - - do - { - /* - * When running in a multi-threaded mode, we pend on the write event - * flag set in the interrupt service routine. This avoids wasting CPU - * cycles waiting in this thread, when we could be doing something - * more profitable elsewhere. - */ - - ALT_FLAG_PEND (sp->events, - ALT_UART_WRITE_RDY, - OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME, - 0); - } - while ((next == sp->tx_start)); - } - } - - count--; - - /* Add the next character to the transmit buffer */ - - sp->tx_buf[sp->tx_end] = *ptr++; - sp->tx_end = next; - } - - /* - * Now that access to the circular buffer is complete, release the write - * semaphore so that other threads can access the buffer. - */ - - ALT_SEM_POST (sp->write_lock); - - /* - * Ensure that interrupts are enabled, so that the circular buffer can - * drain. - */ - - context = alt_irq_disable_all (); - sp->ctrl |= ALTERA_AVALON_UART_CONTROL_TRDY_MSK | - ALTERA_AVALON_UART_CONTROL_DCTS_MSK; - IOWR_ALTERA_AVALON_UART_CONTROL(sp->base, sp->ctrl); - alt_irq_enable_all (context); - - /* return the number of bytes written */ - - return (len - count); -} - -#endif /* fast driver */ diff --git a/ext/hal/altera/drivers/altera_avalon_uart/LWHAL/inc/altera_avalon_uart_lwhal.h b/ext/hal/altera/drivers/altera_avalon_uart/LWHAL/inc/altera_avalon_uart_lwhal.h deleted file mode 100644 index 15f3b82709..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/LWHAL/inc/altera_avalon_uart_lwhal.h +++ /dev/null @@ -1,34 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2010 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALT_AVALON_UART_LWHAL_H__ -#define __ALT_AVALON_UART_LWHAL_H__ - -extern void altera_avalon_uart_lwhal_putchar(void *base, int character); - -#endif /* __ALT_AVALON_UART_LWHAL_H__ */ diff --git a/ext/hal/altera/drivers/altera_avalon_uart/LWHAL/src/CMakeLists.txt b/ext/hal/altera/drivers/altera_avalon_uart/LWHAL/src/CMakeLists.txt deleted file mode 100644 index 5837543664..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/LWHAL/src/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -zephyr_sources(altera_avalon_uart_lwhal_putchar.c) diff --git a/ext/hal/altera/drivers/altera_avalon_uart/LWHAL/src/altera_avalon_uart_lwhal_putchar.c b/ext/hal/altera/drivers/altera_avalon_uart/LWHAL/src/altera_avalon_uart_lwhal_putchar.c deleted file mode 100644 index 02703376e6..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/LWHAL/src/altera_avalon_uart_lwhal_putchar.c +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2010 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include "altera_avalon_uart_regs.h" -#include "altera_avalon_uart_lwhal.h" - - -/** @Function Description: Writes a single character to the UART. - * @API Type: External - * @param base UART base address - * @param character Character to be written - * @return None - * - */ -void altera_avalon_uart_lwhal_putchar(void *base, int character) -{ - unsigned int status; - - do { - status = IORD_ALTERA_AVALON_UART_STATUS(base); - - if (status & ALTERA_AVALON_UART_STATUS_TRDY_MSK) - { - IOWR_ALTERA_AVALON_UART_TXDATA(base, (character & 0xff)); - return; - } - }while (1); - - return; -} diff --git a/ext/hal/altera/drivers/altera_avalon_uart/inc/altera_avalon_uart_regs.h b/ext/hal/altera/drivers/altera_avalon_uart/inc/altera_avalon_uart_regs.h deleted file mode 100644 index 2caf76d5af..0000000000 --- a/ext/hal/altera/drivers/altera_avalon_uart/inc/altera_avalon_uart_regs.h +++ /dev/null @@ -1,135 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALTERA_AVALON_UART_REGS_H__ -#define __ALTERA_AVALON_UART_REGS_H__ - -#include - -#define ALTERA_AVALON_UART_RXDATA_REG 0 -#define IOADDR_ALTERA_AVALON_UART_RXDATA(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_UART_RXDATA_REG) -#define IORD_ALTERA_AVALON_UART_RXDATA(base) \ - IORD(base, ALTERA_AVALON_UART_RXDATA_REG) -#define IOWR_ALTERA_AVALON_UART_RXDATA(base, data) \ - IOWR(base, ALTERA_AVALON_UART_RXDATA_REG, data) - -#define ALTERA_AVALON_UART_TXDATA_REG 1 -#define IOADDR_ALTERA_AVALON_UART_TXDATA(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_UART_TXDATA_REG) -#define IORD_ALTERA_AVALON_UART_TXDATA(base) \ - IORD(base, ALTERA_AVALON_UART_TXDATA_REG) -#define IOWR_ALTERA_AVALON_UART_TXDATA(base, data) \ - IOWR(base, ALTERA_AVALON_UART_TXDATA_REG, data) - -#define ALTERA_AVALON_UART_STATUS_REG 2 -#define IOADDR_ALTERA_AVALON_UART_STATUS(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_UART_STATUS_REG) -#define IORD_ALTERA_AVALON_UART_STATUS(base) \ - IORD(base, ALTERA_AVALON_UART_STATUS_REG) -#define IOWR_ALTERA_AVALON_UART_STATUS(base, data) \ - IOWR(base, ALTERA_AVALON_UART_STATUS_REG, data) - -#define ALTERA_AVALON_UART_STATUS_PE_MSK (0x1) -#define ALTERA_AVALON_UART_STATUS_PE_OFST (0) -#define ALTERA_AVALON_UART_STATUS_FE_MSK (0x2) -#define ALTERA_AVALON_UART_STATUS_FE_OFST (1) -#define ALTERA_AVALON_UART_STATUS_BRK_MSK (0x4) -#define ALTERA_AVALON_UART_STATUS_BRK_OFST (2) -#define ALTERA_AVALON_UART_STATUS_ROE_MSK (0x8) -#define ALTERA_AVALON_UART_STATUS_ROE_OFST (3) -#define ALTERA_AVALON_UART_STATUS_TOE_MSK (0x10) -#define ALTERA_AVALON_UART_STATUS_TOE_OFST (4) -#define ALTERA_AVALON_UART_STATUS_TMT_MSK (0x20) -#define ALTERA_AVALON_UART_STATUS_TMT_OFST (5) -#define ALTERA_AVALON_UART_STATUS_TRDY_MSK (0x40) -#define ALTERA_AVALON_UART_STATUS_TRDY_OFST (6) -#define ALTERA_AVALON_UART_STATUS_RRDY_MSK (0x80) -#define ALTERA_AVALON_UART_STATUS_RRDY_OFST (7) -#define ALTERA_AVALON_UART_STATUS_E_MSK (0x100) -#define ALTERA_AVALON_UART_STATUS_E_OFST (8) -#define ALTERA_AVALON_UART_STATUS_DCTS_MSK (0x400) -#define ALTERA_AVALON_UART_STATUS_DCTS_OFST (10) -#define ALTERA_AVALON_UART_STATUS_CTS_MSK (0x800) -#define ALTERA_AVALON_UART_STATUS_CTS_OFST (11) -#define ALTERA_AVALON_UART_STATUS_EOP_MSK (0x1000) -#define ALTERA_AVALON_UART_STATUS_EOP_OFST (12) - -#define ALTERA_AVALON_UART_CONTROL_REG 3 -#define IOADDR_ALTERA_AVALON_UART_CONTROL(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_UART_CONTROL_REG) -#define IORD_ALTERA_AVALON_UART_CONTROL(base) \ - IORD(base, ALTERA_AVALON_UART_CONTROL_REG) -#define IOWR_ALTERA_AVALON_UART_CONTROL(base, data) \ - IOWR(base, ALTERA_AVALON_UART_CONTROL_REG, data) - -#define ALTERA_AVALON_UART_CONTROL_PE_MSK (0x1) -#define ALTERA_AVALON_UART_CONTROL_PE_OFST (0) -#define ALTERA_AVALON_UART_CONTROL_FE_MSK (0x2) -#define ALTERA_AVALON_UART_CONTROL_FE_OFST (1) -#define ALTERA_AVALON_UART_CONTROL_BRK_MSK (0x4) -#define ALTERA_AVALON_UART_CONTROL_BRK_OFST (2) -#define ALTERA_AVALON_UART_CONTROL_ROE_MSK (0x8) -#define ALTERA_AVALON_UART_CONTROL_ROE_OFST (3) -#define ALTERA_AVALON_UART_CONTROL_TOE_MSK (0x10) -#define ALTERA_AVALON_UART_CONTROL_TOE_OFST (4) -#define ALTERA_AVALON_UART_CONTROL_TMT_MSK (0x20) -#define ALTERA_AVALON_UART_CONTROL_TMT_OFST (5) -#define ALTERA_AVALON_UART_CONTROL_TRDY_MSK (0x40) -#define ALTERA_AVALON_UART_CONTROL_TRDY_OFST (6) -#define ALTERA_AVALON_UART_CONTROL_RRDY_MSK (0x80) -#define ALTERA_AVALON_UART_CONTROL_RRDY_OFST (7) -#define ALTERA_AVALON_UART_CONTROL_E_MSK (0x100) -#define ALTERA_AVALON_UART_CONTROL_E_OFST (8) -#define ALTERA_AVALON_UART_CONTROL_DCTS_MSK (0x400) -#define ALTERA_AVALON_UART_CONTROL_DCTS_OFST (10) -#define ALTERA_AVALON_UART_CONTROL_RTS_MSK (0x800) -#define ALTERA_AVALON_UART_CONTROL_RTS_OFST (11) -#define ALTERA_AVALON_UART_CONTROL_EOP_MSK (0x1000) -#define ALTERA_AVALON_UART_CONTROL_EOP_OFST (12) - -#define ALTERA_AVALON_UART_DIVISOR_REG 4 -#define IOADDR_ALTERA_AVALON_UART_DIVISOR(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_UART_DIVISOR_REG) -#define IORD_ALTERA_AVALON_UART_DIVISOR(base) \ - IORD(base, ALTERA_AVALON_UART_DIVISOR_REG) -#define IOWR_ALTERA_AVALON_UART_DIVISOR(base, data) \ - IOWR(base, ALTERA_AVALON_UART_DIVISOR_REG, data) - -#define ALTERA_AVALON_UART_EOP_REG 5 -#define IOADDR_ALTERA_AVALON_UART_EOP(base) \ - __IO_CALC_ADDRESS_NATIVE(base, ALTERA_AVALON_UART_EOP_REG) -#define IORD_ALTERA_AVALON_UART_EOP(base) \ - IORD(base, ALTERA_AVALON_UART_EOP_REG) -#define IOWR_ALTERA_AVALON_UART_EOP(base, data) \ - IOWR(base, ALTERA_AVALON_UART_EOP_REG, data) - -#define ALTERA_AVALON_UART_EOP_MSK (0xFF) -#define ALTERA_AVALON_UART_EOP_OFST (0) - -#endif /* __ALTERA_AVALON_UART_REGS_H__ */ diff --git a/ext/hal/altera/drivers/altera_epcq_controller/HAL/inc/altera_epcq_controller.h b/ext/hal/altera/drivers/altera_epcq_controller/HAL/inc/altera_epcq_controller.h deleted file mode 100644 index 31b750f496..0000000000 --- a/ext/hal/altera/drivers/altera_epcq_controller/HAL/inc/altera_epcq_controller.h +++ /dev/null @@ -1,124 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2015 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALT_EPCQ_CONTROLLER_H__ -#define __ALT_EPCQ_CONTROLLER_H__ - -#include "alt_types.h" -#include "sys/alt_flash_dev.h" -#include "sys/alt_llist.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/** - * Description of the EPCQ controller - */ -typedef struct alt_epcq_controller_dev -{ - alt_flash_dev dev; - - alt_u32 data_base; /** base address of data slave */ - alt_u32 data_end; /** end address of data slave (not inclusive) */ - alt_u32 csr_base; /** base address of CSR slave */ - alt_u32 size_in_bytes; /** size of memory in bytes */ - alt_u32 is_epcs; /** 1 if device is an EPCS device */ - alt_u32 number_of_sectors; /** number of flash sectors */ - alt_u32 sector_size; /** size of each flash sector */ - alt_u32 page_size; /** page size */ - alt_u32 silicon_id; /** ID of silicon used with EPCQ IP */ -} alt_epcq_controller_dev; - -/** -* Macros used by alt_sys_init.c to create data storage for driver instance -*/ -#define ALTERA_EPCQ_CONTROLLER_AVL_MEM_AVL_CSR_INSTANCE(epcq_name, avl_mem, avl_csr, epcq_dev) \ -static alt_epcq_controller_dev epcq_dev = \ -{ \ - .dev = { \ - .llist = ALT_LLIST_ENTRY, \ - .name = avl_mem##_NAME, \ - .write = alt_epcq_controller_write, \ - .read = alt_epcq_controller_read, \ - .get_info = alt_epcq_controller_get_info, \ - .erase_block = alt_epcq_controller_erase_block, \ - .write_block = alt_epcq_controller_write_block, \ - .base_addr = ((void*)(avl_mem##_BASE)), \ - .length = ((int)(avl_mem##_SPAN)), \ - .lock = alt_epcq_controller_lock , \ - }, \ - .data_base = ((alt_u32)(avl_mem##_BASE)), \ - .data_end = ((alt_u32)(avl_mem##_BASE) + (alt_u32)(avl_mem##_SPAN)), \ - .csr_base = ((alt_u32)(avl_csr##_BASE)), \ - .size_in_bytes = ((alt_u32)(avl_mem##_SPAN)), \ - .is_epcs = ((alt_u32)(avl_mem##_IS_EPCS)), \ - .number_of_sectors = ((alt_u32)(avl_mem##_NUMBER_OF_SECTORS)), \ - .sector_size = ((alt_u32)(avl_mem##_SECTOR_SIZE)), \ - .page_size = ((alt_u32)(avl_mem##_PAGE_SIZE)) , \ -} - -/* - Public API - - Refer to Using Flash Devices in the - Developing Programs Using the Hardware Abstraction Layer chapter - of the Nios II Software Developer's Handbook. - -*/ -int alt_epcq_controller_read(alt_flash_dev *flash_info, int offset, void *dest_addr, int length); - -int alt_epcq_controller_get_info(alt_flash_fd *fd, flash_region **info, int *number_of_regions); - -int alt_epcq_controller_erase_block(alt_flash_dev *flash_info, int block_offset); - -int alt_epcq_controller_write_block(alt_flash_dev *flash_info, int block_offset, int data_offset, const void *data, int length); - -int alt_epcq_controller_write(alt_flash_dev *flash_info, int offset, const void *src_addr, int length); - -int alt_epcq_controller_lock(alt_flash_dev *flash_info, alt_u32 sectors_to_lock); - - -/* - * Initialization function - */ -extern alt_32 altera_epcq_controller_init(alt_epcq_controller_dev *dev); - -/* - * alt_sys_init.c will call this macro automatically initialize the driver instance - */ -#define ALTERA_EPCQ_CONTROLLER_INIT(name, dev) \ - altera_epcq_controller_init(&dev); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_EPCQ_CONTROLLER_H__ */ diff --git a/ext/hal/altera/drivers/altera_epcq_controller/HAL/src/CMakeLists.txt b/ext/hal/altera/drivers/altera_epcq_controller/HAL/src/CMakeLists.txt deleted file mode 100644 index 2250bb3f4a..0000000000 --- a/ext/hal/altera/drivers/altera_epcq_controller/HAL/src/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -zephyr_sources(altera_epcq_controller.c) diff --git a/ext/hal/altera/drivers/altera_epcq_controller/HAL/src/altera_epcq_controller.c b/ext/hal/altera/drivers/altera_epcq_controller/HAL/src/altera_epcq_controller.c deleted file mode 100644 index 79f8e2fc96..0000000000 --- a/ext/hal/altera/drivers/altera_epcq_controller/HAL/src/altera_epcq_controller.c +++ /dev/null @@ -1,793 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2015 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#include -#include -#include -#include -#include "sys/param.h" -#include "alt_types.h" -#include "altera_epcq_controller_regs.h" -#include "altera_epcq_controller.h" -#include "priv/alt_busy_sleep.h" -#include "sys/alt_debug.h" -#include "sys/alt_cache.h" - - -ALT_INLINE alt_32 static alt_epcq_validate_read_write_arguments(alt_epcq_controller_dev *flash_info,alt_u32 offset, alt_u32 length); -alt_32 static alt_epcq_poll_for_write_in_progress(alt_epcq_controller_dev* epcq_flash_info); - -/* - * Public API - * - * Refer to “Using Flash Devices†in the - * Developing Programs Using the Hardware Abstraction Layer chapter - * of the Nios II Software Developer’s Handbook. - */ - - - /** - * alt_epcq_controller_lock - * - * Locks the range of the memory sectors, which - * protected from write and erase. - * - * Arguments: - * - *flash_info: Pointer to general flash device structure. - * - sectors_to_lock: Block protection bits in EPCQ ==> Bit4 | Bit3 | Bit2 | Bit1 | Bit0 - * TB | BP3 | BP2 | BP1 | BP0 - * For details of setting sectors protection, please refer to EPCQ datasheet. - * - * Returns: - * 0 -> success - * -EINVAL -> Invalid arguments - * -ETIME -> Time out and skipping the looping after 0.7 sec. - * -ENOLCK -> Sectors lock failed. -**/ -int alt_epcq_controller_lock(alt_flash_dev *flash_info, alt_u32 sectors_to_lock) -{ - alt_u32 mem_op_value = 0; /* value to write to EPCQ_MEM_OP register */ - alt_epcq_controller_dev* epcq_flash_info = NULL; - alt_u32 result = 0; - alt_32 status = 0; - - /* return -EINVAL if flash_info is NULL */ - if(NULL == flash_info || 0 > sectors_to_lock) - { - return -EINVAL; - } - - epcq_flash_info = (alt_epcq_controller_dev*)flash_info; - - /* sector value should occupy bits 17:8 */ - mem_op_value = sectors_to_lock << 8; - - /* sector protect commands 0b11 occupies lower 2 bits */ - mem_op_value |= ALTERA_EPCQ_CONTROLLER_MEM_OP_SECTOR_PROTECT_CMD; - - /* write sector protect command to EPCQ_MEM_OP register to protect sectors */ - IOWR_ALTERA_EPCQ_CONTROLLER_MEM_OP(epcq_flash_info->csr_base, mem_op_value); - - /* poll write in progress to make sure no operation is in progress */ - status = alt_epcq_poll_for_write_in_progress(epcq_flash_info); - if(status != 0) - { - return status; - } - - status = IORD_ALTERA_EPCQ_CONTROLLER_STATUS(epcq_flash_info->csr_base); - result |= (status >> 2) & 0x07; /* extract out BP3 - BP0 */ - result |= (status >> 3) & 0x08; /* extract out BP4 */ - result |= (status >> 1) & 0x10; /* extract out TOP/BOTTOM bit */ - - if(result != sectors_to_lock) - { - return -ENOLCK; - } - - return 0; -} - -/** - * alt_epcq_controller_get_info - * - * Pass the table of erase blocks to the user. This flash will return a single - * flash_region that gives the number and size of sectors for the device used. - * - * Arguments: - * - *fd: Pointer to general flash device structure. - * - **info: Pointer to flash region - * - *number_of_regions: Pointer to number of regions - * - * For details of setting sectors protection, please refer to EPCQ datasheet. - * - * Returns: - * 0 -> success - * -EINVAL -> Invalid arguments - * -EIO -> Could be hardware problem. -**/ -int alt_epcq_controller_get_info -( - alt_flash_fd *fd, /** flash device descriptor */ - flash_region **info, /** pointer to flash_region will be stored here */ - int *number_of_regions /** number of regions will be stored here */ -) -{ - alt_flash_dev* flash = NULL; - - /* return -EINVAL if fd,info and number_of_regions are NULL */ - if(NULL == fd || NULL == info || NULL == number_of_regions) - { - return -EINVAL; - } - - flash = (alt_flash_dev*)fd; - - *number_of_regions = flash->number_of_regions; - - if (!flash->number_of_regions) - { - return -EIO; - } - else - { - *info = &flash->region_info[0]; - } - - return 0; -} - -/** - * alt_epcq_controller_erase_block - * - * This function erases a single flash sector. - * - * Arguments: - * - *flash_info: Pointer to EPCQ flash device structure. - * - block_offset: byte-addressed offset, from start of flash, of the sector to be erased - * - * Returns: - * 0 -> success - * -EINVAL -> Invalid arguments - * -EIO -> write failed, sector might be protected -**/ -int alt_epcq_controller_erase_block(alt_flash_dev *flash_info, int block_offset) -{ - alt_32 ret_code = 0; - alt_u32 mem_op_value = 0; /* value to write to EPCQ_MEM_OP register */ - alt_epcq_controller_dev* epcq_flash_info = NULL; - alt_u32 sector_number = 0; - - /* return -EINVAL if flash_info is NULL */ - if(NULL == flash_info) - { - return -EINVAL; - } - - epcq_flash_info = (alt_epcq_controller_dev*)flash_info; - - /* - * Sanity checks that block_offset is within the flash memory span and that the - * block offset is sector aligned. - * - */ - if((block_offset < 0) - || (block_offset >= epcq_flash_info->size_in_bytes) - || (block_offset & (epcq_flash_info->sector_size - 1)) != 0) - { - return -EINVAL; - } - - /* calculate current sector/block number */ - sector_number = (block_offset/(epcq_flash_info->sector_size)); - - /* sector value should occupy bits 23:8 */ - mem_op_value = (sector_number << 8) & ALTERA_EPCQ_CONTROLLER_MEM_OP_SECTOR_VALUE_MASK; - - /* sector erase commands 0b10 occupies lower 2 bits */ - mem_op_value |= ALTERA_EPCQ_CONTROLLER_MEM_OP_SECTOR_ERASE_CMD; - - /* write sector erase command to EPCQ_MEM_OP register to erase sector "sector_number" */ - IOWR_ALTERA_EPCQ_CONTROLLER_MEM_OP(epcq_flash_info->csr_base, mem_op_value); - - /* check whether erase triggered a illegal erase interrupt */ - if((IORD_ALTERA_EPCQ_CONTROLLER_ISR(epcq_flash_info->csr_base) & - ALTERA_EPCQ_CONTROLLER_ISR_ILLEGAL_ERASE_MASK) == - ALTERA_EPCQ_CONTROLLER_ISR_ILLEGAL_ERASE_ACTIVE) - { - /* clear register */ - /* EPCQ_ISR access is write one to clear (W1C) */ - IOWR_ALTERA_EPCQ_CONTROLLER_ISR(epcq_flash_info->csr_base, - ALTERA_EPCQ_CONTROLLER_ISR_ILLEGAL_ERASE_MASK ); - return -EIO; /* erase failed, sector might be protected */ - } - - return ret_code; -} - -/** - * alt_epcq_controller_write_block - * - * This function writes one block/sector of data to flash. The length of the write can NOT - * spill into the adjacent sector. - * - * It assumes that someone has already erased the appropriate sector(s). - * - * Arguments: - * - *flash_info: Pointer to EPCQ flash device structure. - * - block_offset: byte-addressed offset, from the start of flash, of the sector to written to - * - data-offset: Byte offset (unaligned access) of write into flash memory. - * For best performance, word(32 bits - aligned access) offset of write is recommended. - * - *src_addr: source buffer - * - length: size of writing - * - * Returns: - * 0 -> success - * -EINVAL -> Invalid arguments - * -EIO -> write failed, sector might be protected -**/ -int alt_epcq_controller_write_block -( - alt_flash_dev *flash_info, /** flash device info */ - int block_offset, /** sector/block offset in byte addressing */ - int data_offset, /** offset of write from base address */ - const void *data, /** data to be written */ - int length /** bytes of data to be written, >0 */ -) -{ - alt_u32 buffer_offset = 0; /** offset into data buffer to get write data */ - alt_u32 remaining_length = length; /** length left to write */ - alt_u32 write_offset = data_offset; /** offset into flash to write too */ - - alt_epcq_controller_dev *epcq_flash_info = (alt_epcq_controller_dev*)flash_info; - - /* - * Sanity checks that data offset is not larger then a sector, that block offset is - * sector aligned and within the valid flash memory range and a write doesn't spill into - * the adjacent flash sector. - */ - if(block_offset < 0 - || data_offset < 0 - || NULL == flash_info - || NULL == data - || data_offset >= epcq_flash_info->size_in_bytes - || block_offset >= epcq_flash_info->size_in_bytes - || length > (epcq_flash_info->sector_size - (data_offset - block_offset)) - || length < 0 - || (block_offset & (epcq_flash_info->sector_size - 1)) != 0) - { - return -EINVAL; - } - - /* - * Do writes one 32-bit word at a time. - * We need to make sure that we pad the first few bytes so they're word aligned if they are - * not already. - */ - while (remaining_length > 0) - { - alt_u32 word_to_write = 0xFFFFFFFF; /** initialize word to write to blank word */ - alt_u32 padding = 0; /** bytes to pad the next word that is written */ - alt_u32 bytes_to_copy = sizeof(alt_u32); /** number of bytes from source to copy */ - - /* - * we need to make sure the write is word aligned - * this should only be true at most 1 time - */ - if (0 != (write_offset & (sizeof(alt_u32) - 1))) - { - /* - * data is not word aligned - * calculate padding bytes need to add before start of a data offset - */ - padding = write_offset & (sizeof(alt_u32) - 1); - - /* update variables to account for padding being added */ - bytes_to_copy -= padding; - - if(bytes_to_copy > remaining_length) - { - bytes_to_copy = remaining_length; - } - - write_offset = write_offset - padding; - if(0 != (write_offset & (sizeof(alt_u32) - 1))) - { - return -EINVAL; - } - } - else - { - if(bytes_to_copy > remaining_length) - { - bytes_to_copy = remaining_length; - } - } - - /* prepare the word to be written */ - memcpy((((void*)&word_to_write)) + padding, ((void*)data) + buffer_offset, bytes_to_copy); - - /* update offset and length variables */ - buffer_offset += bytes_to_copy; - remaining_length -= bytes_to_copy; - - /* write to flash 32 bits at a time */ - IOWR_32DIRECT(epcq_flash_info->data_base, write_offset, word_to_write); - - /* check whether write triggered a illegal write interrupt */ - if((IORD_ALTERA_EPCQ_CONTROLLER_ISR(epcq_flash_info->csr_base) & - ALTERA_EPCQ_CONTROLLER_ISR_ILLEGAL_WRITE_MASK) == - ALTERA_EPCQ_CONTROLLER_ISR_ILLEGAL_WRITE_ACTIVE) - { - /* clear register */ - IOWR_ALTERA_EPCQ_CONTROLLER_ISR(epcq_flash_info->csr_base, - ALTERA_EPCQ_CONTROLLER_ISR_ILLEGAL_WRITE_MASK ); - return -EIO; /** write failed, sector might be protected */ - } - - /* update current offset */ - write_offset = write_offset + sizeof(alt_u32); - } - - return 0; -} - -/** - * alt_epcq_controller_write - * - * Program the data into the flash at the selected address. - * - * The different between this function and alt_epcq_controller_write_block function - * is that this function (alt_epcq_controller_write) will automatically erase a block as needed - * Arguments: - * - *flash_info: Pointer to EPCQ flash device structure. - * - offset: Byte offset (unaligned access) of write to flash memory. For best performance, - * word(32 bits - aligned access) offset of write is recommended. - * - *src_addr: source buffer - * - length: size of writing - * - * Returns: - * 0 -> success - * -EINVAL -> Invalid arguments - * -EIO -> write failed, sector might be protected - * -**/ -int alt_epcq_controller_write( - alt_flash_dev *flash_info, /** device info */ - int offset, /** offset of write from base address */ - const void *src_addr, /** source buffer */ - int length /** size of writing */ -) -{ - alt_32 ret_code = 0; - - alt_epcq_controller_dev *epcq_flash_info = NULL; - - alt_u32 write_offset = offset; /** address of next byte to write */ - alt_u32 remaining_length = length; /** length of write data left to be written */ - alt_u32 buffer_offset = 0; /** offset into source buffer to get write data */ - alt_u32 i = 0; - - /* return -EINVAL if flash_info and src_addr are NULL */ - if(NULL == flash_info || NULL == src_addr) - { - return -EINVAL; - } - - epcq_flash_info = (alt_epcq_controller_dev*)flash_info; - - /* make sure the write parameters are within the bounds of the flash */ - ret_code = alt_epcq_validate_read_write_arguments(epcq_flash_info, offset, length); - - if(0 != ret_code) - { - return ret_code; - } - - /* - * This loop erases and writes data one sector at a time. We check for write completion - * before starting the next sector. - */ - for(i = offset/epcq_flash_info->sector_size ; i < epcq_flash_info->number_of_sectors; i++) - { - alt_u32 block_offset = 0; /** block offset in byte addressing */ - alt_u32 offset_within_current_sector = 0; /** offset into current sector to write */ - alt_u32 length_to_write = 0; /** length to write to current sector */ - - if(0 >= remaining_length) - { - break; /* out of data to write */ - } - - /* calculate current sector/block offset in byte addressing */ - block_offset = write_offset & ~(epcq_flash_info->sector_size - 1); - - /* calculate offset into sector/block if there is one */ - if(block_offset != write_offset) - { - offset_within_current_sector = write_offset - block_offset; - } - - /* erase sector */ - ret_code = alt_epcq_controller_erase_block(flash_info, block_offset); - - if(0 != ret_code) - { - return ret_code; - } - - /* calculate the byte size of data to be written in a sector */ - length_to_write = MIN(epcq_flash_info->sector_size - offset_within_current_sector, - remaining_length); - - /* write data to erased block */ - ret_code = alt_epcq_controller_write_block(flash_info, block_offset, write_offset, - src_addr + buffer_offset, length_to_write); - - - if(0 != ret_code) - { - return ret_code; - } - - /* update remaining length and buffer_offset pointer */ - remaining_length -= length_to_write; - buffer_offset += length_to_write; - write_offset += length_to_write; - } - - return ret_code; -} - -/** - * alt_epcq_controller_read - * - * There's no real need to use this function as opposed to using memcpy directly. It does - * do some sanity checks on the bounds of the read. - * - * Arguments: - * - *flash_info: Pointer to general flash device structure. - * - offset: offset read from flash memory. - * - *dest_addr: destination buffer - * - length: size of reading - * - * Returns: - * 0 -> success - * -EINVAL -> Invalid arguments -**/ -int alt_epcq_controller_read -( - alt_flash_dev *flash_info, /** device info */ - int offset, /** offset of read from base address */ - void *dest_addr, /** destination buffer */ - int length /** size of read */ -) -{ - alt_32 ret_code = 0; - alt_epcq_controller_dev *epcq_flash_info = NULL; - - /* return -EINVAL if flash_info and dest_addr are NULL */ - if(NULL == flash_info || NULL == dest_addr) - { - return -EINVAL; - } - - epcq_flash_info = (alt_epcq_controller_dev*)flash_info; - - /* validate arguments */ - ret_code = alt_epcq_validate_read_write_arguments(epcq_flash_info, offset, length); - - /* copy data from flash to destination address */ - if(0 == ret_code) - { - memcpy(dest_addr, (alt_u8*)epcq_flash_info->data_base + offset, length); - } - - return ret_code; -} - -/** - * altera_epcq_controller_init - * - * alt_sys_init.c will call this function automatically through macro - * - * Information in system.h is checked against expected values that are determined by the silicon_id. - * If the information doesn't match then this system is configured incorrectly. Most likely the wrong - * type of EPCS or EPCQ device was selected when instantiating the soft IP. - * - * Arguments: - * - *flash: Pointer to EPCQ flash device structure. - * - * Returns: - * 0 -> success - * -EINVAL -> Invalid arguments. - * -ENODEV -> System is configured incorrectly. -**/ -alt_32 altera_epcq_controller_init(alt_epcq_controller_dev *flash) -{ - alt_u32 silicon_id = 0; - alt_u32 size_in_bytes = 0; - alt_u32 number_of_sectors = 0; - - /* return -EINVAL if flash is NULL */ - if(NULL == flash) - { - return -EINVAL; - } - - /* return -ENODEV if CSR slave is not attached */ - if(NULL == (void *)flash->csr_base) - { - return -ENODEV; - } - - - /* - * If flash is an EPCQ device, we read the EPCQ_RD_RDID register for the ID - * If flash is an EPCS device, we read the EPCQ_RD_SID register for the ID - * - * Whether or not the flash is a EPCQ or EPCS is indicated in the system.h. The system.h gets - * this value from the hw.tcl of the IP. If this value is set incorrectly, then things will go - * badly. - * - * In both cases, we can determine the number of sectors, which we can use - * to calculate a size. We compare that size to the system.h value to make sure - * the EPCQ soft IP was configured correctly. - */ - if(0 == flash->is_epcs) - { - /* If we're an EPCQ, we read EPCQ_RD_RDID for the silicon ID */ - silicon_id = IORD_ALTERA_EPCQ_CONTROLLER_RDID(flash->csr_base); - silicon_id &= ALTERA_EPCQ_CONTROLLER_RDID_MASK; - - /* Determine which EPCQ device so we can figure out the number of sectors */ - /* EPCQ share the same ID for the same capacity*/ - switch(silicon_id) - { - case ALTERA_EPCQ_CONTROLLER_RDID_EPCQ16: - { - number_of_sectors = 32; - break; - } - case ALTERA_EPCQ_CONTROLLER_RDID_EPCQ32: - { - number_of_sectors = 64; - break; - } - case ALTERA_EPCQ_CONTROLLER_RDID_EPCQ64: - { - number_of_sectors = 128; - break; - } - case ALTERA_EPCQ_CONTROLLER_RDID_EPCQ128: - { - number_of_sectors = 256; - break; - } - case ALTERA_EPCQ_CONTROLLER_RDID_EPCQ256: - { - number_of_sectors = 512; - break; - } - case ALTERA_EPCQ_CONTROLLER_RDID_EPCQ512: - { - number_of_sectors = 1024; - break; - } - case ALTERA_EPCQ_CONTROLLER_RDID_EPCQ1024: - { - number_of_sectors = 2048; - break; - } - default: - { - return -ENODEV; - } - } - } - else { - /* If we're an EPCS, we read EPCQ_RD_SID for the silicon ID */ - silicon_id = IORD_ALTERA_EPCQ_CONTROLLER_SID(flash->csr_base); - silicon_id &= ALTERA_EPCQ_CONTROLLER_SID_MASK; - - /* Determine which EPCS device so we can figure out various properties */ - switch(silicon_id) - { - case ALTERA_EPCQ_CONTROLLER_SID_EPCS16: - { - number_of_sectors = 32; - break; - } - case ALTERA_EPCQ_CONTROLLER_SID_EPCS64: - { - number_of_sectors = 128; - break; - } - case ALTERA_EPCQ_CONTROLLER_SID_EPCS128: - { - number_of_sectors = 256; - break; - } - default: - { - return -ENODEV; - } - } - } - - /* Calculate size of flash based on number of sectors */ - size_in_bytes = number_of_sectors * flash->sector_size; - - /* - * Make sure calculated size is the same size given in system.h - * Also check number of sectors is the same number given in system.h - * Otherwise the EPCQ IP was not configured correctly - */ - if( size_in_bytes != flash->size_in_bytes || - number_of_sectors != flash->number_of_sectors) - { - flash->dev.number_of_regions = 0; - return -ENODEV; - } - else - { - flash->silicon_id = silicon_id; - flash->number_of_sectors = number_of_sectors; - - /* - * populate fields of region_info required to conform to HAL API - * create 1 region that composed of "number_of_sectors" blocks - */ - flash->dev.number_of_regions = 1; - flash->dev.region_info[0].offset = 0; - flash->dev.region_info[0].region_size = size_in_bytes; - flash->dev.region_info[0].number_of_blocks = number_of_sectors; - flash->dev.region_info[0].block_size = flash->sector_size; - } - - - /* - * Register this device as a valid flash device type - * - * Only register the device if it's configured correctly. - */ - alt_flash_device_register(&(flash->dev)); - - - return 0; -} - - -/* - * Private API - * - * Helper functions used by Public API functions. - * - * Arguments: - * - *flash_info: Pointer to EPCQ flash device structure. - * - offset: Offset of read/write from base address. - * - length: Length of read/write in bytes. - * - * Returns: - * 0 -> success - * -EINVAL -> Invalid arguments - */ -/** - * Used to check that arguments to a read or write are valid - */ -ALT_INLINE alt_32 static alt_epcq_validate_read_write_arguments -( - alt_epcq_controller_dev *flash_info, /** device info */ - alt_u32 offset, /** offset of read/write */ - alt_u32 length /** length of read/write */ -) -{ - alt_epcq_controller_dev *epcq_flash_info = NULL; - alt_u32 start_address = 0; - alt_32 end_address = 0; - - /* return -EINVAL if flash_info is NULL */ - if(NULL == flash_info) - { - return -EINVAL; - } - - epcq_flash_info = (alt_epcq_controller_dev*)flash_info; - - start_address = epcq_flash_info->data_base + offset; /** first address of read or write */ - end_address = start_address + length; /** last address of read or write (not inclusive) */ - - /* make sure start and end address is less then the end address of the flash */ - if( - start_address >= epcq_flash_info->data_end || - end_address > epcq_flash_info->data_end || - offset < 0 || - length < 0 - ) - { - return -EINVAL; - } - - return 0; -} - -/* - * Private function that polls write in progress bit EPCQ_RD_STATUS. - * - * Write in progress will be set if any of the following operations are in progress: - * -WRITE STATUS REGISTER - * -WRITE NONVOLATILE CONFIGURATION REGISTER - * -PROGRAM - * -ERASE - * - * Assumes EPCQ was configured correctly. - * - * If ALTERA_EPCQ_CONTROLLER_1US_TIMEOUT_VALUE is set, the function will time out after - * a period of time determined by that value. - * - * Arguments: - * - *epcq_flash_info: Pointer to EPCQ flash device structure. - * - * Returns: - * 0 -> success - * -EINVAL -> Invalid arguments - * -ETIME -> Time out and skipping the looping after 0.7 sec. - */ -alt_32 static alt_epcq_poll_for_write_in_progress(alt_epcq_controller_dev* epcq_flash_info) -{ - /* we'll want to implement timeout if a timeout value is specified */ -#if ALTERA_EPCQ_CONTROLLER_1US_TIMEOUT_VALUE > 0 - alt_u32 timeout = ALTERA_EPCQ_CONTROLLER_1US_TIMEOUT_VALUE; - alt_u16 counter = 0; -#endif - - /* return -EINVAL if epcq_flash_info is NULL */ - if(NULL == epcq_flash_info) - { - return -EINVAL; - } - - /* while Write in Progress bit is set, we wait */ - while((IORD_ALTERA_EPCQ_CONTROLLER_STATUS(epcq_flash_info->csr_base) & - ALTERA_EPCQ_CONTROLLER_STATUS_WIP_MASK) == - ALTERA_EPCQ_CONTROLLER_STATUS_WIP_BUSY) - { - alt_busy_sleep(1); /* delay 1us */ -#if ALTERA_EPCQ_CONTROLLER_1US_TIMEOUT_VALUE > 0 - if(timeout <= counter ) - { - return -ETIME; - } - - counter++; -#endif - - } - - return 0; -} diff --git a/ext/hal/altera/drivers/altera_epcq_controller/inc/altera_epcq_controller_regs.h b/ext/hal/altera/drivers/altera_epcq_controller/inc/altera_epcq_controller_regs.h deleted file mode 100644 index 5f69563874..0000000000 --- a/ext/hal/altera/drivers/altera_epcq_controller/inc/altera_epcq_controller_regs.h +++ /dev/null @@ -1,258 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2014 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALTERA_EPCQ_CONTROLLER_REGS_H__ -#define __ALTERA_EPCQ_CONTROLLER_REGS_H__ - -#include - -/* - * EPCQ_RD_STATUS register offset - * - * The EPCQ_RD_STATUS register contains information from the read status - * register operation. A full description of the register can be found in the - * data sheet, - * - */ -#define ALTERA_EPCQ_CONTROLLER_STATUS_REG (0x0) - -/* - * EPCQ_RD_STATUS register access macros - */ -#define IOADDR_ALTERA_EPCQ_CONTROLLER_STATUS(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_EPCQ_CONTROLLER_STATUS_REG) - -#define IORD_ALTERA_EPCQ_CONTROLLER_STATUS(base) \ - IORD_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_STATUS_REG) - -#define IOWR_ALTERA_EPCQ_CONTROLLER_STATUS(base, data) \ - IOWR_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_STATUS_REG, data) - -/* - * EPCQ_RD_STATUS register description macros - */ - -/** Write in progress bit */ -#define ALTERA_EPCQ_CONTROLLER_STATUS_WIP_MASK (0x00000001) -#define ALTERA_EPCQ_CONTROLLER_STATUS_WIP_AVAILABLE (0x00000000) -#define ALTERA_EPCQ_CONTROLLER_STATUS_WIP_BUSY (0x00000001) -/** When to time out a poll of the write in progress bit */ -/* 0.7 sec time out */ -#define ALTERA_EPCQ_CONTROLLER_1US_TIMEOUT_VALUE 700000 - -/* - * EPCQ_RD_SID register offset - * - * The EPCQ_RD_SID register contains the information from the read silicon ID - * operation and can be used to determine what type of EPCS device we have. - * Only support in EPCS16 and EPCS64. - * - * This register is valid only if the device is an EPCS. - * - */ -#define ALTERA_EPCQ_CONTROLLER_SID_REG (0x4) - -/* - * EPCQ_RD_SID register access macros - */ -#define IOADDR_ALTERA_EPCQ_CONTROLLER_SID(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_EPCQ_CONTROLLER_SID_REG) - -#define IORD_ALTERA_EPCQ_CONTROLLER_SID(base) \ - IORD_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_SID_REG) - -#define IOWR_ALTERA_EPCQ_CONTROLLER_SID(base, data) \ - IOWR_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_SID_REG, data) - -/* - * EPCQ_RD_SID register description macros - * - * Specific device values obtained from Table 14 of: - * "Serial Configuration (EPCS) Devices Datasheet" - */ -#define ALTERA_EPCQ_CONTROLLER_SID_MASK (0x000000FF) -#define ALTERA_EPCQ_CONTROLLER_SID_EPCS16 (0x00000014) -#define ALTERA_EPCQ_CONTROLLER_SID_EPCS64 (0x00000016) -#define ALTERA_EPCQ_CONTROLLER_SID_EPCS128 (0x00000018) - -/* - * EPCQ_RD_RDID register offset - * - * The EPCQ_RD_RDID register contains the information from the read memory - * capacity operation and can be used to determine what type of EPCQ device - * we have. - * - * This register is only valid if the device is an EPCQ. - * - */ -#define ALTERA_EPCQ_CONTROLLER_RDID_REG (0x8) - -/* - * EPCQ_RD_RDID register access macros - */ -#define IOADDR_ALTERA_EPCQ_CONTROLLER_RDID(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_EPCQ_CONTROLLER_RDID_REG) - -#define IORD_ALTERA_EPCQ_CONTROLLER_RDID(base) \ - IORD_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_RDID_REG) - -#define IOWR_ALTERA_EPCQ_CONTROLLER_RDID(base, data) \ - IOWR_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_RDID_REG, data) - -/* - * EPCQ_RD_RDID register description macros - * - * Specific device values obtained from Table 28 of: - * "Quad-Serial Configuration (EPCQ (www.altera.com/literature/hb/cfg/cfg_cf52012.pdf)) - * Devices Datasheet" - */ -#define ALTERA_EPCQ_CONTROLLER_RDID_MASK (0x000000FF) -#define ALTERA_EPCQ_CONTROLLER_RDID_EPCQ16 (0x00000015) -#define ALTERA_EPCQ_CONTROLLER_RDID_EPCQ32 (0x00000016) -#define ALTERA_EPCQ_CONTROLLER_RDID_EPCQ64 (0x00000017) -#define ALTERA_EPCQ_CONTROLLER_RDID_EPCQ128 (0x00000018) -#define ALTERA_EPCQ_CONTROLLER_RDID_EPCQ256 (0x00000019) -#define ALTERA_EPCQ_CONTROLLER_RDID_EPCQ512 (0x00000020) -#define ALTERA_EPCQ_CONTROLLER_RDID_EPCQ1024 (0x00000021) - -/* - * EPCQ_MEM_OP register offset - * - * The EPCQ_MEM_OP register is used to do memory protect and erase operations - * - */ -#define ALTERA_EPCQ_CONTROLLER_MEM_OP_REG (0xC) - -/* - * EPCQ_MEM_OP register access macros - */ -#define IOADDR_ALTERA_EPCQ_CONTROLLER_MEM_OP(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_EPCQ_CONTROLLER_MEM_OP_REG) - -#define IORD_ALTERA_EPCQ_CONTROLLER_MEM_OP(base) \ - IORD_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_MEM_OP_REG) - -#define IOWR_ALTERA_EPCQ_CONTROLLER_MEM_OP(base, data) \ - IOWR_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_MEM_OP_REG, data) - -/* - * EPCQ_MEM_OP register description macros - */ -#define ALTERA_EPCQ_CONTROLLER_MEM_OP_CMD_MASK (0x00000003) -#define ALTERA_EPCQ_CONTROLLER_MEM_OP_BULK_ERASE_CMD (0x00000001) -#define ALTERA_EPCQ_CONTROLLER_MEM_OP_SECTOR_ERASE_CMD (0x00000002) -#define ALTERA_EPCQ_CONTROLLER_MEM_OP_SECTOR_PROTECT_CMD (0x00000003) - -/** see datasheet for sector values */ -#define ALTERA_EPCQ_CONTROLLER_MEM_OP_SECTOR_VALUE_MASK (0x00FFFF00) - -/* - * EPCQ_ISR register offset - * - * The EPCQ_ISR register is used to determine whether an invalid write or erase - * operation triggered an interrupt - * - */ -#define ALTERA_EPCQ_CONTROLLER_ISR_REG (0x10) - -/* - * EPCQ_ISR register access macros - */ -#define IOADDR_ALTERA_EPCQ_CONTROLLER_ISR(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_EPCQ_CONTROLLER_ISR_REG) - -#define IORD_ALTERA_EPCQ_CONTROLLER_ISR(base) \ - IORD_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_ISR_REG) - -#define IOWR_ALTERA_EPCQ_CONTROLLER_ISR(base, data) \ - IOWR_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_ISR_REG, data) - -/* - * EPCQ_ISR register description macros - */ -#define ALTERA_EPCQ_CONTROLLER_ISR_ILLEGAL_ERASE_MASK (0x00000001) -#define ALTERA_EPCQ_CONTROLLER_ISR_ILLEGAL_ERASE_ACTIVE (0x00000001) - -#define ALTERA_EPCQ_CONTROLLER_ISR_ILLEGAL_WRITE_MASK (0x00000002) -#define ALTERA_EPCQ_CONTROLLER_ISR_ILLEGAL_WRITE_ACTIVE (0x00000002) - - -/* - * EPCQ_IMR register offset - * - * The EPCQ_IMR register is used to mask the invalid erase or the invalid write - * interrupts. - * - */ -#define ALTERA_EPCQ_CONTROLLER_IMR_REG (0x14) - -/* - * EPCQ_IMR register access macros - */ -#define IOADDR_ALTERA_EPCQ_CONTROLLER_IMR(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_EPCQ_CONTROLLER_IMR_REG) - -#define IORD_ALTERA_EPCQ_CONTROLLER_IMR(base) \ - IORD_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_IMR_REG) - -#define IOWR_ALTERA_EPCQ_CONTROLLER_IMR(base, data) \ - IOWR_32DIRECT(base, ALTERA_EPCQ_CONTROLLER_IMR_REG, data) - -/* - * EPCQ_IMR register description macros - */ -#define ALTERA_EPCQ_CONTROLLER_IMR_ILLEGAL_ERASE_MASK (0x00000001) -#define ALTERA_EPCQ_CONTROLLER_IMR_ILLEGAL_ERASE_ENABLED (0x00000001) - -#define ALTERA_EPCQ_CONTROLLER_IMR_ILLEGAL_WRITE_MASK (0x00000002) -#define ALTERA_EPCQ_CONTROLLER_IMR_ILLEGAL_WRITE_ENABLED (0x00000002) - -/* - * EPCQ_CHIP_SELECT register offset - * - * The EPCQ_CHIP_SELECT register is used to issue chip select - */ -#define ALTERA_EPCQ_CHIP_SELECT_REG (0x18) - -/* - * EPCQ_CHIP_SELECT register access macros - */ -#define IOADDR_ALTERA_EPCQ_CHIP_SELECT(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_EPCQ_CHIP_SELECT_REG) - -#define IOWR_ALTERA_EPCQ_CHIP_SELECT(base, data) \ - IOWR_32DIRECT(base, ALTERA_EPCQ_CHIP_SELECT_REG, data) - -/* - * EPCQ_CHIP_SELECT register description macros - */ -#define ALTERA_EPCQ_CHIP1_SELECT (0x00000001) -#define ALTERA_EPCQ_CHIP2_SELECT (0x00000002) -#define ALTERA_EPCQ_CHIP3_SELECT (0x00000003) - -#endif /* __ALTERA_EPCQ_CONTROLLER_REGS_H__ */ diff --git a/ext/hal/altera/drivers/altera_generic_qspi_controller2/HAL/inc/altera_generic_quad_spi_controller2.h b/ext/hal/altera/drivers/altera_generic_qspi_controller2/HAL/inc/altera_generic_quad_spi_controller2.h deleted file mode 100644 index 9eedfa74b0..0000000000 --- a/ext/hal/altera/drivers/altera_generic_qspi_controller2/HAL/inc/altera_generic_quad_spi_controller2.h +++ /dev/null @@ -1,129 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2015 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALT_QSPI_CONTROLLER2_H__ -#define __ALT_QSPI_CONTROLLER2_H__ - -#include "alt_types.h" -#include "sys/alt_flash_dev.h" -#include "sys/alt_llist.h" - - -#ifdef __cplusplus -extern "C" -{ - -#endif /* __cplusplus */ - - - -/** - * Description of the QSPI controller - */ -typedef struct alt_qspi_controller2_dev -{ - alt_flash_dev dev; - - - alt_u32 data_base; /** base address of data slave */ - alt_u32 data_end; /** end address of data slave (not inclusive) */ - alt_u32 csr_base; /** base address of CSR slave */ - alt_u32 size_in_bytes; /** size of memory in bytes */ - alt_u32 is_epcs; /** 1 if device is an EPCS device */ - alt_u32 number_of_sectors; /** number of flash sectors */ - alt_u32 sector_size; /** size of each flash sector */ - alt_u32 page_size; /** page size */ - alt_u32 silicon_id; /** ID of silicon used with EPCQ/QSPI IP */ -} alt_qspi_controller2_dev; - - -/** -* Macros used by alt_sys_init.c to create data storage for driver instance -*/ - -#define ALTERA_GENERIC_QUAD_SPI_CONTROLLER2_AVL_MEM_AVL_CSR_INSTANCE(qspi_name, avl_mem, avl_csr, qspi_dev) \ -static alt_qspi_controller2_dev qspi_dev = \ -{ \ - .dev = { \ - .llist = ALT_LLIST_ENTRY, \ - .name = avl_mem##_NAME, \ - .write = alt_qspi_controller2_write, \ - .read = alt_qspi_controller2_read, \ - .get_info = alt_qspi_controller2_get_info, \ - .erase_block = alt_qspi_controller2_erase_block, \ - .write_block = alt_qspi_controller2_write_block, \ - .base_addr = ((void*)(avl_mem##_BASE)), \ - .length = ((int)(avl_mem##_SPAN)), \ - .lock = alt_qspi_controller2_lock , \ - }, \ - .data_base = ((alt_u32)(avl_mem##_BASE)), \ - .data_end = ((alt_u32)(avl_mem##_BASE) + (alt_u32)(avl_mem##_SPAN)), \ - .csr_base = ((alt_u32)(avl_csr##_BASE)), \ - .size_in_bytes = ((alt_u32)(avl_mem##_SPAN)), \ - .is_epcs = ((alt_u32)(avl_mem##_IS_EPCS)), \ - .number_of_sectors = ((alt_u32)(avl_mem##_NUMBER_OF_SECTORS)), \ - .sector_size = ((alt_u32)(avl_mem##_SECTOR_SIZE)), \ - .page_size = ((alt_u32)(avl_mem##_PAGE_SIZE)) , \ -} - -/* - Public API - Refer to Using Flash Devices in the - Developing Programs Using the Hardware Abstraction Layer chapter - of the Nios II Software Developer's Handbook. -*/ - -int alt_qspi_controller2_read(alt_flash_dev *flash_info, int offset, void *dest_addr, int length); - -int alt_qspi_controller2_get_info(alt_flash_fd *fd, flash_region **info, int *number_of_regions); - -int alt_qspi_controller2_erase_block(alt_flash_dev *flash_info, int block_offset); - -int alt_qspi_controller2_write_block(alt_flash_dev *flash_info, int block_offset, int data_offset, const void *data, int length); - -int alt_qspi_controller2_write(alt_flash_dev *flash_info, int offset, const void *src_addr, int length); - -int alt_qspi_controller2_lock(alt_flash_dev *flash_info, alt_u32 sectors_to_lock); - - -/* - * Initialization function - */ -extern alt_32 altera_qspi_controller2_init(alt_qspi_controller2_dev *dev); - -/* - * alt_sys_init.c will call this macro automatically initialize the driver instance - */ - -#define ALTERA_GENERIC_QUAD_SPI_CONTROLLER2_INIT(name, dev) \ - altera_qspi_controller2_init(&dev); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __ALT_QSPI_CONTROLLER2_H__ */ diff --git a/ext/hal/altera/drivers/altera_generic_qspi_controller2/HAL/src/altera_generic_quad_spi_controller2.c b/ext/hal/altera/drivers/altera_generic_qspi_controller2/HAL/src/altera_generic_quad_spi_controller2.c deleted file mode 100644 index 2259828910..0000000000 --- a/ext/hal/altera/drivers/altera_generic_qspi_controller2/HAL/src/altera_generic_quad_spi_controller2.c +++ /dev/null @@ -1,1516 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2015 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - - -#include -#include -#include -#include -#include "sys/param.h" -#include "alt_types.h" -#include "altera_generic_quad_spi_controller2_regs.h" -#include "altera_generic_quad_spi_controller2.h" -#include "priv/alt_busy_sleep.h" -#include "sys/alt_debug.h" -#include "sys/alt_cache.h" - -ALT_INLINE alt_32 static alt_qspi_validate_read_write_arguments(alt_qspi_controller2_dev *flash_info,alt_u32 offset, alt_u32 length); -alt_32 static alt_qspi_poll_for_write_in_progress(alt_qspi_controller2_dev* qspi_flash_info); - - -/* - * Public API - * - * Refer to “Using Flash Devices†in the - * Developing Programs Using the Hardware Abstraction Layer chapter - * of the Nios II Software Developer’s Handbook. - */ - - - /** - * alt_qspi_controller2_lock - * - * Locks the range of the memory sectors, which - * protected from write and erase. - * - * Arguments: - * - *flash_info: Pointer to general flash device structure. - * - sectors_to_lock: Block protection bits in EPCQ/QSPI ==> Bit4 | Bit3 | Bit2 | Bit1 | Bit0 - * TB | BP3 | BP2 | BP1 | BP0 - * For details of setting sectors protection, please refer to EPCQ/QSPI datasheet. - * - * Returns: - * 0 -> success - * -EINVAL -> Invalid arguments - * -ETIME -> Time out and skipping the looping after 0.7 sec. - * -ENOLCK -> Sectors lock failed. -**/ - -int alt_qspi_controller2_lock(alt_flash_dev *flash_info, alt_u32 sectors_to_lock) - -{ - - alt_u32 mem_op_value = 0; /* value to write to EPCQ_MEM_OP register */ - - alt_qspi_controller2_dev* qspi_flash_info = NULL; - - alt_u32 result = 0; - - alt_32 status = 0; - - - - /* return -EINVAL if flash_info is NULL */ - - if(NULL == flash_info || 0 > sectors_to_lock) - - { - - return -EINVAL; - - } - - - - qspi_flash_info = (alt_qspi_controller2_dev*)flash_info; - - - - /* sector value should occupy bits 17:8 */ - - mem_op_value = sectors_to_lock << 8; - - - - /* sector protect commands 0b11 occupies lower 2 bits */ - - mem_op_value |= ALTERA_QSPI_CONTROLLER2_MEM_OP_SECTOR_PROTECT_CMD; - - - - /* write sector protect command to QSPI_MEM_OP register to protect sectors */ - - IOWR_ALTERA_QSPI_CONTROLLER2_MEM_OP(qspi_flash_info->csr_base, mem_op_value); - - - - /* poll write in progress to make sure no operation is in progress */ - - status = alt_qspi_poll_for_write_in_progress(qspi_flash_info); - - if(status != 0) - - { - - return status; - - } - - - - status = IORD_ALTERA_QSPI_CONTROLLER2_STATUS(qspi_flash_info->csr_base); - - result |= (status >> 2) & 0x07; /* extract out BP3 - BP0 */ - - result |= (status >> 3) & 0x08; /* extract out BP4 */ - - result |= (status >> 1) & 0x10; /* extract out TOP/BOTTOM bit */ - - - - if(result != sectors_to_lock) - - { - - return -ENOLCK; - - } - - - - return 0; - -} - - - -/** - - * alt_qspi_controller2_get_info - - * - - * Pass the table of erase blocks to the user. This flash will return a single - - * flash_region that gives the number and size of sectors for the device used. - - * - - * Arguments: - - * - *fd: Pointer to general flash device structure. - - * - **info: Pointer to flash region - - * - *number_of_regions: Pointer to number of regions - - * - - * For details of setting sectors protection, please refer to EPCQ/QSPI datasheet. - - * - - * Returns: - - * 0 -> success - - * -EINVAL -> Invalid arguments - - * -EIO -> Could be hardware problem. - -**/ - -int alt_qspi_controller2_get_info - -( - - alt_flash_fd *fd, /** flash device descriptor */ - - flash_region **info, /** pointer to flash_region will be stored here */ - - int *number_of_regions /** number of regions will be stored here */ - -) - -{ - - alt_flash_dev* flash = NULL; - - - - /* return -EINVAL if fd,info and number_of_regions are NULL */ - - if(NULL == fd || NULL == info || NULL == number_of_regions) - - { - - return -EINVAL; - - } - - - - flash = (alt_flash_dev*)fd; - - - - *number_of_regions = flash->number_of_regions; - - - - if (!flash->number_of_regions) - - { - - return -EIO; - - } - - else - - { - - *info = &flash->region_info[0]; - - } - - - - return 0; - -} - - - -/** - - * alt_qspi_controller2_erase_block - - * - - * This function erases a single flash sector. - - * - - * Arguments: - - * - *flash_info: Pointer to QSPI flash device structure. - - * - block_offset: byte-addressed offset, from start of flash, of the sector to be erased - - * - - * Returns: - - * 0 -> success - - * -EINVAL -> Invalid arguments - - * -EIO -> write failed, sector might be protected - -**/ - -int alt_qspi_controller2_erase_block(alt_flash_dev *flash_info, int block_offset) - -{ - - alt_32 ret_code = 0; - - alt_u32 mem_op_value = 0; /* value to write to EPCQ_MEM_OP register */ - - alt_qspi_controller2_dev* qspi_flash_info = NULL; - - alt_u32 sector_number = 0; - - - - /* return -EINVAL if flash_info is NULL */ - - if(NULL == flash_info) - - { - - return -EINVAL; - - } - - - - qspi_flash_info = (alt_qspi_controller2_dev*)flash_info; - - - - /* - - * Sanity checks that block_offset is within the flash memory span and that the - - * block offset is sector aligned. - - * - - */ - - if((block_offset < 0) - - || (block_offset >= qspi_flash_info->size_in_bytes) - - || (block_offset & (qspi_flash_info->sector_size - 1)) != 0) - - { - - return -EINVAL; - - } - - - - /* calculate current sector/block number */ - - sector_number = (block_offset/(qspi_flash_info->sector_size)); - - - - /* sector value should occupy bits 23:8 */ - - mem_op_value = (sector_number << 8) & ALTERA_QSPI_CONTROLLER2_MEM_OP_SECTOR_VALUE_MASK; - - - - /* sector erase commands 0b10 occupies lower 2 bits */ - - mem_op_value |= ALTERA_QSPI_CONTROLLER2_MEM_OP_SECTOR_ERASE_CMD; - - - - /* write sector erase command to QSPI_MEM_OP register to erase sector "sector_number" */ - - IOWR_ALTERA_QSPI_CONTROLLER2_MEM_OP(qspi_flash_info->csr_base, mem_op_value); - - - - /* check whether erase triggered a illegal erase interrupt */ - - if((IORD_ALTERA_QSPI_CONTROLLER2_ISR(qspi_flash_info->csr_base) & - - ALTERA_QSPI_CONTROLLER2_ISR_ILLEGAL_ERASE_MASK) == - - ALTERA_QSPI_CONTROLLER2_ISR_ILLEGAL_ERASE_ACTIVE) - - { - - /* clear register */ - - /* QSPI_ISR access is write one to clear (W1C) */ - - IOWR_ALTERA_QSPI_CONTROLLER2_ISR(qspi_flash_info->csr_base, - - ALTERA_QSPI_CONTROLLER2_ISR_ILLEGAL_ERASE_MASK ); - - return -EIO; /* erase failed, sector might be protected */ - - } - - - - return ret_code; - -} - - - -/** - - * alt_qspi_controller2_write_block - - * - - * This function writes one block/sector of data to flash. The length of the write can NOT - - * spill into the adjacent sector. - - * - - * It assumes that someone has already erased the appropriate sector(s). - - * - - * Arguments: - - * - *flash_info: Pointer to QSPI flash device structure. - - * - block_offset: byte-addressed offset, from the start of flash, of the sector to written to - - * - data-offset: Byte offset (unaligned access) of write into flash memory. - - * For best performance, word(32 bits - aligned access) offset of write is recommended. - - * - *src_addr: source buffer - - * - length: size of writing - - * - - * Returns: - - * 0 -> success - - * -EINVAL -> Invalid arguments - - * -EIO -> write failed, sector might be protected - -**/ - -int alt_qspi_controller2_write_block - -( - - alt_flash_dev *flash_info, /** flash device info */ - - int block_offset, /** sector/block offset in byte addressing */ - - int data_offset, /** offset of write from base address */ - - const void *data, /** data to be written */ - - int length /** bytes of data to be written, >0 */ - -) - -{ - - alt_u32 buffer_offset = 0; /** offset into data buffer to get write data */ - - alt_u32 remaining_length = length; /** length left to write */ - - alt_u32 write_offset = data_offset; /** offset into flash to write too */ - - - - alt_qspi_controller2_dev *qspi_flash_info = (alt_qspi_controller2_dev*)flash_info; - - - - /* - - * Sanity checks that data offset is not larger then a sector, that block offset is - - * sector aligned and within the valid flash memory range and a write doesn't spill into - - * the adjacent flash sector. - - */ - - if(block_offset < 0 - - || data_offset < 0 - - || NULL == flash_info - - || NULL == data - - || data_offset >= qspi_flash_info->size_in_bytes - - || block_offset >= qspi_flash_info->size_in_bytes - - || length > (qspi_flash_info->sector_size - (data_offset - block_offset)) - - || length < 0 - - || (block_offset & (qspi_flash_info->sector_size - 1)) != 0) - - { - - return -EINVAL; - - } - - - - /* - - * Do writes one 32-bit word at a time. - - * We need to make sure that we pad the first few bytes so they're word aligned if they are - - * not already. - - */ - - while (remaining_length > 0) - - { - - alt_u32 word_to_write = 0xFFFFFFFF; /** initialize word to write to blank word */ - - alt_u32 padding = 0; /** bytes to pad the next word that is written */ - - alt_u32 bytes_to_copy = sizeof(alt_u32); /** number of bytes from source to copy */ - - - - /* - - * we need to make sure the write is word aligned - - * this should only be true at most 1 time - - */ - - if (0 != (write_offset & (sizeof(alt_u32) - 1))) - - { - - /* - - * data is not word aligned - - * calculate padding bytes need to add before start of a data offset - - */ - - padding = write_offset & (sizeof(alt_u32) - 1); - - - - /* update variables to account for padding being added */ - - bytes_to_copy -= padding; - - - - if(bytes_to_copy > remaining_length) - - { - - bytes_to_copy = remaining_length; - - } - - - - write_offset = write_offset - padding; - - if(0 != (write_offset & (sizeof(alt_u32) - 1))) - - { - - return -EINVAL; - - } - - } - - else - - { - - if(bytes_to_copy > remaining_length) - - { - - bytes_to_copy = remaining_length; - - } - - } - - - - /* prepare the word to be written */ - - memcpy((((void*)&word_to_write)) + padding, ((void*)data) + buffer_offset, bytes_to_copy); - - - - /* update offset and length variables */ - - buffer_offset += bytes_to_copy; - - remaining_length -= bytes_to_copy; - - - - /* write to flash 32 bits at a time */ - - IOWR_32DIRECT(qspi_flash_info->data_base, write_offset, word_to_write); - - - - /* check whether write triggered a illegal write interrupt */ - - if((IORD_ALTERA_QSPI_CONTROLLER2_ISR(qspi_flash_info->csr_base) & - - ALTERA_QSPI_CONTROLLER2_ISR_ILLEGAL_WRITE_MASK) == - - ALTERA_QSPI_CONTROLLER2_ISR_ILLEGAL_WRITE_ACTIVE) - - { - - /* clear register */ - - IOWR_ALTERA_QSPI_CONTROLLER2_ISR(qspi_flash_info->csr_base, - - ALTERA_QSPI_CONTROLLER2_ISR_ILLEGAL_WRITE_MASK ); - - return -EIO; /** write failed, sector might be protected */ - - } - - - - /* update current offset */ - - write_offset = write_offset + sizeof(alt_u32); - - } - - - - return 0; - -} - - - -/** - - * alt_qspi_controller2_write - - * - - * Program the data into the flash at the selected address. - - * - - * The different between this function and alt_qspi_controller2_write_block function - - * is that this function (alt_qspi_controller2_write) will automatically erase a block as needed - - * Arguments: - - * - *flash_info: Pointer to QSPI flash device structure. - - * - offset: Byte offset (unaligned access) of write to flash memory. For best performance, - - * word(32 bits - aligned access) offset of write is recommended. - - * - *src_addr: source buffer - - * - length: size of writing - - * - - * Returns: - - * 0 -> success - - * -EINVAL -> Invalid arguments - - * -EIO -> write failed, sector might be protected - - * - -**/ - -int alt_qspi_controller2_write( - - alt_flash_dev *flash_info, /** device info */ - - int offset, /** offset of write from base address */ - - const void *src_addr, /** source buffer */ - - int length /** size of writing */ - -) - -{ - - alt_32 ret_code = 0; - - - - alt_qspi_controller2_dev *qspi_flash_info = NULL; - - - - alt_u32 write_offset = offset; /** address of next byte to write */ - - alt_u32 remaining_length = length; /** length of write data left to be written */ - - alt_u32 buffer_offset = 0; /** offset into source buffer to get write data */ - - alt_u32 i = 0; - - - - /* return -EINVAL if flash_info and src_addr are NULL */ - - if(NULL == flash_info || NULL == src_addr) - - { - - return -EINVAL; - - } - - - - qspi_flash_info = (alt_qspi_controller2_dev*)flash_info; - - - - /* make sure the write parameters are within the bounds of the flash */ - - ret_code = alt_qspi_validate_read_write_arguments(qspi_flash_info, offset, length); - - - - if(0 != ret_code) - - { - - return ret_code; - - } - - - - /* - - * This loop erases and writes data one sector at a time. We check for write completion - - * before starting the next sector. - - */ - - for(i = offset/qspi_flash_info->sector_size ; i < qspi_flash_info->number_of_sectors; i++) - - { - - alt_u32 block_offset = 0; /** block offset in byte addressing */ - - alt_u32 offset_within_current_sector = 0; /** offset into current sector to write */ - - alt_u32 length_to_write = 0; /** length to write to current sector */ - - - - if(0 >= remaining_length) - - { - - break; /* out of data to write */ - - } - - - - /* calculate current sector/block offset in byte addressing */ - - block_offset = write_offset & ~(qspi_flash_info->sector_size - 1); - - - - /* calculate offset into sector/block if there is one */ - - if(block_offset != write_offset) - - { - - offset_within_current_sector = write_offset - block_offset; - - } - - - - /* erase sector */ - - ret_code = alt_qspi_controller2_erase_block(flash_info, block_offset); - - - - if(0 != ret_code) - - { - - return ret_code; - - } - - - - /* calculate the byte size of data to be written in a sector */ - - length_to_write = MIN(qspi_flash_info->sector_size - offset_within_current_sector, - - remaining_length); - - - - /* write data to erased block */ - - ret_code = alt_qspi_controller2_write_block(flash_info, block_offset, write_offset, - - src_addr + buffer_offset, length_to_write); - - - - - - if(0 != ret_code) - - { - - return ret_code; - - } - - - - /* update remaining length and buffer_offset pointer */ - - remaining_length -= length_to_write; - - buffer_offset += length_to_write; - - write_offset += length_to_write; - - } - - - - return ret_code; - -} - - - -/** - - * alt_qspi_controller2_read - - * - - * There's no real need to use this function as opposed to using memcpy directly. It does - - * do some sanity checks on the bounds of the read. - - * - - * Arguments: - - * - *flash_info: Pointer to general flash device structure. - - * - offset: offset read from flash memory. - - * - *dest_addr: destination buffer - - * - length: size of reading - - * - - * Returns: - - * 0 -> success - - * -EINVAL -> Invalid arguments - -**/ - -int alt_qspi_controller2_read - -( - - alt_flash_dev *flash_info, /** device info */ - - int offset, /** offset of read from base address */ - - void *dest_addr, /** destination buffer */ - - int length /** size of read */ - -) - -{ - - alt_32 ret_code = 0; - - alt_qspi_controller2_dev *qspi_flash_info = NULL; - - - - /* return -EINVAL if flash_info and dest_addr are NULL */ - - if(NULL == flash_info || NULL == dest_addr) - - { - - return -EINVAL; - - } - - - - qspi_flash_info = (alt_qspi_controller2_dev*)flash_info; - - - - /* validate arguments */ - - ret_code = alt_qspi_validate_read_write_arguments(qspi_flash_info, offset, length); - - - - /* copy data from flash to destination address */ - - if(0 == ret_code) - - { - - memcpy(dest_addr, (alt_u8*)qspi_flash_info->data_base + offset, length); - - } - - - - return ret_code; - -} - - - -/** - - * altera_qspi_controller2_init - - * - - * alt_sys_init.c will call this function automatically through macro - - * - - * Information in system.h is checked against expected values that are determined by the silicon_id. - - * If the information doesn't match then this system is configured incorrectly. Most likely the wrong - - * type of EPCS or EPCQ/QSPI device was selected when instantiating the soft IP. - - * - - * Arguments: - - * - *flash: Pointer to QSPI flash device structure. - - * - - * Returns: - - * 0 -> success - - * -EINVAL -> Invalid arguments. - - * -ENODEV -> System is configured incorrectly. - -**/ - -alt_32 altera_qspi_controller2_init(alt_qspi_controller2_dev *flash) - -{ - - alt_u32 silicon_id = 0; - - alt_u32 size_in_bytes = 0; - - alt_u32 number_of_sectors = 0; - - - - /* return -EINVAL if flash is NULL */ - - if(NULL == flash) - - { - - return -EINVAL; - - } - - - - /* return -ENODEV if CSR slave is not attached */ - - if(NULL == (void *)flash->csr_base) - - { - - return -ENODEV; - - } - - - - - - /* - - * If flash is an EPCQ/QSPI device, we read the QSPI_RD_RDID register for the ID - - * If flash is an EPCS device, we read the QSPI_RD_SID register for the ID - - * - - * Whether or not the flash is a EPCQ, QSPI or EPCS is indicated in the system.h. The system.h gets - - * this value from the hw.tcl of the IP. If this value is set incorrectly, then things will go - - * badly. - - * - - * In both cases, we can determine the number of sectors, which we can use - - * to calculate a size. We compare that size to the system.h value to make sure - - * the QSPI soft IP was configured correctly. - - */ - - if(0 == flash->is_epcs) - - { - - /* If we're an EPCQ or QSPI, we read QSPI_RD_RDID for the silicon ID */ - - silicon_id = IORD_ALTERA_QSPI_CONTROLLER2_RDID(flash->csr_base); - - silicon_id &= ALTERA_QSPI_CONTROLLER2_RDID_MASK; - - - - /* Determine which EPCQ/QSPI device so we can figure out the number of sectors */ - - /*EPCQ and QSPI share the same ID for the same capacity*/ - - switch(silicon_id) - - { - - case ALTERA_QSPI_CONTROLLER2_RDID_QSPI16: - - { - - number_of_sectors = 32; - - break; - - } - - case ALTERA_QSPI_CONTROLLER2_RDID_QSPI32: - - { - - number_of_sectors = 64; - - break; - - } - - case ALTERA_QSPI_CONTROLLER2_RDID_QSPI64: - - { - - number_of_sectors = 128; - - break; - - } - - case ALTERA_QSPI_CONTROLLER2_RDID_QSPI128: - - { - - number_of_sectors = 256; - - break; - - } - - case ALTERA_QSPI_CONTROLLER2_RDID_QSPI256: - - { - - number_of_sectors = 512; - - break; - - } - - case ALTERA_QSPI_CONTROLLER2_RDID_QSPI512: - - { - - number_of_sectors = 1024; - - break; - - } - - case ALTERA_QSPI_CONTROLLER2_RDID_QSPI1024: - - { - - number_of_sectors = 2048; - - break; - - } - - default: - - { - - return -ENODEV; - - } - - } - - } - - else { - - /* If we're an EPCS, we read QSPI_RD_SID for the silicon ID */ - - silicon_id = IORD_ALTERA_QSPI_CONTROLLER2_SID(flash->csr_base); - - silicon_id &= ALTERA_QSPI_CONTROLLER2_SID_MASK; - - - - /* Determine which EPCS device so we can figure out various properties */ - - switch(silicon_id) - - { - - case ALTERA_QSPI_CONTROLLER2_SID_EPCS16: - - { - - number_of_sectors = 32; - - break; - - } - - case ALTERA_QSPI_CONTROLLER2_SID_EPCS64: - - { - - number_of_sectors = 128; - - break; - - } - - case ALTERA_QSPI_CONTROLLER2_SID_EPCS128: - - { - - number_of_sectors = 256; - - break; - - } - - default: - - { - - return -ENODEV; - - } - - } - - } - - - - /* Calculate size of flash based on number of sectors */ - - size_in_bytes = number_of_sectors * flash->sector_size; - - - - /* - - * Make sure calculated size is the same size given in system.h - - * Also check number of sectors is the same number given in system.h - - * Otherwise the QSPI IP was not configured correctly - - */ - - if( size_in_bytes != flash->size_in_bytes || - - number_of_sectors != flash->number_of_sectors) - - { - - flash->dev.number_of_regions = 0; - - return -ENODEV; - - } - - else - - { - - flash->silicon_id = silicon_id; - - flash->number_of_sectors = number_of_sectors; - - - - /* - - * populate fields of region_info required to conform to HAL API - - * create 1 region that composed of "number_of_sectors" blocks - - */ - - flash->dev.number_of_regions = 1; - - flash->dev.region_info[0].offset = 0; - - flash->dev.region_info[0].region_size = size_in_bytes; - - flash->dev.region_info[0].number_of_blocks = number_of_sectors; - - flash->dev.region_info[0].block_size = flash->sector_size; - - } - - - - - - /* - - * Register this device as a valid flash device type - - * - - * Only register the device if it's configured correctly. - - */ - - alt_flash_device_register(&(flash->dev)); - - - - - - return 0; - -} - - - - - -/* - - * Private API - - * - - * Helper functions used by Public API functions. - - * - - * Arguments: - - * - *flash_info: Pointer to QSPI flash device structure. - - * - offset: Offset of read/write from base address. - - * - length: Length of read/write in bytes. - - * - - * Returns: - - * 0 -> success - - * -EINVAL -> Invalid arguments - - */ - -/** - - * Used to check that arguments to a read or write are valid - - */ - -ALT_INLINE alt_32 static alt_qspi_validate_read_write_arguments - -( - - alt_qspi_controller2_dev *flash_info, /** device info */ - - alt_u32 offset, /** offset of read/write */ - - alt_u32 length /** length of read/write */ - -) - -{ - - alt_qspi_controller2_dev *qspi_flash_info = NULL; - - alt_u32 start_address = 0; - - alt_32 end_address = 0; - - - - /* return -EINVAL if flash_info is NULL */ - - if(NULL == flash_info) - - { - - return -EINVAL; - - } - - - - qspi_flash_info = (alt_qspi_controller2_dev*)flash_info; - - - - start_address = qspi_flash_info->data_base + offset; /** first address of read or write */ - - end_address = start_address + length; /** last address of read or write (not inclusive) */ - - - - /* make sure start and end address is less then the end address of the flash */ - - if( - - start_address >= qspi_flash_info->data_end || - - end_address >= qspi_flash_info->data_end || - - offset < 0 || - - length < 0 - - ) - - { - - return -EINVAL; - - } - - - - return 0; - -} - - - -/* - - * Private function that polls write in progress bit QSPI_RD_STATUS. - - * - - * Write in progress will be set if any of the following operations are in progress: - - * -WRITE STATUS REGISTER - - * -WRITE NONVOLATILE CONFIGURATION REGISTER - - * -PROGRAM - - * -ERASE - - * - - * Assumes QSPI was configured correctly. - - * - - * If ALTERA_QSPI_CONTROLLER2_1US_TIMEOUT_VALUE is set, the function will time out after - - * a period of time determined by that value. - - * - - * Arguments: - - * - *qspi_flash_info: Pointer to QSPI flash device structure. - - * - - * Returns: - - * 0 -> success - - * -EINVAL -> Invalid arguments - - * -ETIME -> Time out and skipping the looping after 0.7 sec. - - */ - -alt_32 static alt_qspi_poll_for_write_in_progress(alt_qspi_controller2_dev* qspi_flash_info) - -{ - - /* we'll want to implement timeout if a timeout value is specified */ - -#if ALTERA_QSPI_CONTROLLER2_1US_TIMEOUT_VALUE > 0 - - alt_u32 timeout = ALTERA_QSPI_CONTROLLER2_1US_TIMEOUT_VALUE; - - alt_u16 counter = 0; - -#endif - - - - /* return -EINVAL if qspi_flash_info is NULL */ - - if(NULL == qspi_flash_info) - - { - - return -EINVAL; - - } - - - - /* while Write in Progress bit is set, we wait */ - - while((IORD_ALTERA_QSPI_CONTROLLER2_STATUS(qspi_flash_info->csr_base) & - - ALTERA_QSPI_CONTROLLER2_STATUS_WIP_MASK) == - - ALTERA_QSPI_CONTROLLER2_STATUS_WIP_BUSY) - - { - - alt_busy_sleep(1); /* delay 1us */ - -#if ALTERA_QSPI_CONTROLLER2_1US_TIMEOUT_VALUE > 0 - - if(timeout <= counter ) - - { - - return -ETIME; - - } - - - - counter++; - -#endif - - - - } - - - - return 0; - -} diff --git a/ext/hal/altera/drivers/altera_generic_qspi_controller2/inc/altera_generic_quad_spi_controller2_regs.h b/ext/hal/altera/drivers/altera_generic_qspi_controller2/inc/altera_generic_quad_spi_controller2_regs.h deleted file mode 100644 index e0aed12f2b..0000000000 --- a/ext/hal/altera/drivers/altera_generic_qspi_controller2/inc/altera_generic_quad_spi_controller2_regs.h +++ /dev/null @@ -1,258 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2014 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALTERA_QSPI_CONTROLLER2_REGS_H__ -#define __ALTERA_QSPI_CONTROLLER2_REGS_H__ - -#include - -/* - * QSPI_RD_STATUS register offset - * - * The QSPI_RD_STATUS register contains information from the read status - * register operation. A full description of the register can be found in the - * data sheet, - * - */ -#define ALTERA_QSPI_CONTROLLER2_STATUS_REG (0x0) - -/* - * QSPI_RD_STATUS register access macros - */ -#define IOADDR_ALTERA_QSPI_CONTROLLER2_STATUS(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_QSPI_CONTROLLER2_STATUS_REG) - -#define IORD_ALTERA_QSPI_CONTROLLER2_STATUS(base) \ - IORD_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_STATUS_REG) - -#define IOWR_ALTERA_QSPI_CONTROLLER2_STATUS(base, data) \ - IOWR_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_STATUS_REG, data) - -/* - * QSPI_RD_STATUS register description macros - */ - -/** Write in progress bit */ -#define ALTERA_QSPI_CONTROLLER2_STATUS_WIP_MASK (0x00000001) -#define ALTERA_QSPI_CONTROLLER2_STATUS_WIP_AVAILABLE (0x00000000) -#define ALTERA_QSPI_CONTROLLER2_STATUS_WIP_BUSY (0x00000001) -/** When to time out a poll of the write in progress bit */ -/* 0.7 sec time out */ -#define ALTERA_QSPI_CONTROLLER2_1US_TIMEOUT_VALUE 700000 - -/* - * QSPI_RD_SID register offset - * - * The QSPI_RD_SID register contains the information from the read silicon ID - * operation and can be used to determine what type of EPCS device we have. - * Only support in EPCS16 and EPCS64. - * - * This register is valid only if the device is an EPCS. - * - */ -#define ALTERA_QSPI_CONTROLLER2_SID_REG (0x4) - -/* - * QSPI_RD_SID register access macros - */ -#define IOADDR_ALTERA_QSPI_CONTROLLER2_SID(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_QSPI_CONTROLLER2_SID_REG) - -#define IORD_ALTERA_QSPI_CONTROLLER2_SID(base) \ - IORD_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_SID_REG) - -#define IOWR_ALTERA_QSPI_CONTROLLER2_SID(base, data) \ - IOWR_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_SID_REG, data) - -/* - * QSPI_RD_SID register description macros - * - * Specific device values obtained from Table 14 of: - * "Serial Configuration (EPCS) Devices Datasheet" - */ -#define ALTERA_QSPI_CONTROLLER2_SID_MASK (0x000000FF) -#define ALTERA_QSPI_CONTROLLER2_SID_EPCS16 (0x00000014) -#define ALTERA_QSPI_CONTROLLER2_SID_EPCS64 (0x00000016) -#define ALTERA_QSPI_CONTROLLER2_SID_EPCS128 (0x00000018) - -/* - * QSPI_RD_RDID register offset - * - * The QSPI_RD_RDID register contains the information from the read memory - * capacity operation and can be used to determine what type of EPCQ/QSPI device - * we have. - * - * This register is only valid if the device is an EPCQ/QSPI. - * - */ -#define ALTERA_QSPI_CONTROLLER2_RDID_REG (0x8) - -/* - * QSPI_RD_RDID register access macros - */ -#define IOADDR_ALTERA_QSPI_CONTROLLER2_RDID(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_QSPI_CONTROLLER2_RDID_REG) - -#define IORD_ALTERA_QSPI_CONTROLLER2_RDID(base) \ - IORD_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_RDID_REG) - -#define IOWR_ALTERA_QSPI_CONTROLLER2_RDID(base, data) \ - IOWR_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_RDID_REG, data) - -/* - * QSPI_RD_RDID register description macros - * - * Specific device values obtained from Table 28 of: - * "Quad-Serial Configuration (EPCQ/QSPI? (www.altera.com/literature/hb/cfg/cfg_cf52012.pdf)) - * Devices Datasheet" - */ -#define ALTERA_QSPI_CONTROLLER2_RDID_MASK (0x000000FF) -#define ALTERA_QSPI_CONTROLLER2_RDID_QSPI16 (0x00000015) -#define ALTERA_QSPI_CONTROLLER2_RDID_QSPI32 (0x00000016) -#define ALTERA_QSPI_CONTROLLER2_RDID_QSPI64 (0x00000017) -#define ALTERA_QSPI_CONTROLLER2_RDID_QSPI128 (0x00000018) -#define ALTERA_QSPI_CONTROLLER2_RDID_QSPI256 (0x00000019) -#define ALTERA_QSPI_CONTROLLER2_RDID_QSPI512 (0x00000020) -#define ALTERA_QSPI_CONTROLLER2_RDID_QSPI1024 (0x00000021) - -/* - * QSPI_MEM_OP register offset - * - * The QSPI_MEM_OP register is used to do memory protect and erase operations - * - */ -#define ALTERA_QSPI_CONTROLLER2_MEM_OP_REG (0xC) - -/* - * QSPI_MEM_OP register access macros - */ -#define IOADDR_ALTERA_QSPI_CONTROLLER2_MEM_OP(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_QSPI_CONTROLLER2_MEM_OP_REG) - -#define IORD_ALTERA_QSPI_CONTROLLER2_MEM_OP(base) \ - IORD_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_MEM_OP_REG) - -#define IOWR_ALTERA_QSPI_CONTROLLER2_MEM_OP(base, data) \ - IOWR_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_MEM_OP_REG, data) - -/* - * QSPI_MEM_OP register description macros - */ -#define ALTERA_QSPI_CONTROLLER2_MEM_OP_CMD_MASK (0x00000003) -#define ALTERA_QSPI_CONTROLLER2_MEM_OP_BULK_ERASE_CMD (0x00000001) -#define ALTERA_QSPI_CONTROLLER2_MEM_OP_SECTOR_ERASE_CMD (0x00000002) -#define ALTERA_QSPI_CONTROLLER2_MEM_OP_SECTOR_PROTECT_CMD (0x00000003) - -/** see datasheet for sector values */ -#define ALTERA_QSPI_CONTROLLER2_MEM_OP_SECTOR_VALUE_MASK (0x00FFFF00) - -/* - * QSPI_ISR register offset - * - * The QSPI_ISR register is used to determine whether an invalid write or erase - * operation triggered an interrupt - * - */ -#define ALTERA_QSPI_CONTROLLER2_ISR_REG (0x10) - -/* - * QSPI_ISR register access macros - */ -#define IOADDR_ALTERA_QSPI_CONTROLLER2_ISR(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_QSPI_CONTROLLER2_ISR_REG) - -#define IORD_ALTERA_QSPI_CONTROLLER2_ISR(base) \ - IORD_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_ISR_REG) - -#define IOWR_ALTERA_QSPI_CONTROLLER2_ISR(base, data) \ - IOWR_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_ISR_REG, data) - -/* - * QSPI_ISR register description macros - */ -#define ALTERA_QSPI_CONTROLLER2_ISR_ILLEGAL_ERASE_MASK (0x00000001) -#define ALTERA_QSPI_CONTROLLER2_ISR_ILLEGAL_ERASE_ACTIVE (0x00000001) - -#define ALTERA_QSPI_CONTROLLER2_ISR_ILLEGAL_WRITE_MASK (0x00000002) -#define ALTERA_QSPI_CONTROLLER2_ISR_ILLEGAL_WRITE_ACTIVE (0x00000002) - - -/* - * QSPI_IMR register offset - * - * The QSPI_IMR register is used to mask the invalid erase or the invalid write - * interrupts. - * - */ -#define ALTERA_QSPI_CONTROLLER2_IMR_REG (0x14) - -/* - * QSPI_IMR register access macros - */ -#define IOADDR_ALTERA_QSPI_CONTROLLER2_IMR(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_QSPI_CONTROLLER2_IMR_REG) - -#define IORD_ALTERA_QSPI_CONTROLLER2_IMR(base) \ - IORD_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_IMR_REG) - -#define IOWR_ALTERA_QSPI_CONTROLLER2_IMR(base, data) \ - IOWR_32DIRECT(base, ALTERA_QSPI_CONTROLLER2_IMR_REG, data) - -/* - * QSPI_IMR register description macros - */ -#define ALTERA_QSPI_CONTROLLER2_IMR_ILLEGAL_ERASE_MASK (0x00000001) -#define ALTERA_QSPI_CONTROLLER2_IMR_ILLEGAL_ERASE_ENABLED (0x00000001) - -#define ALTERA_QSPI_CONTROLLER2_IMR_ILLEGAL_WRITE_MASK (0x00000002) -#define ALTERA_QSPI_CONTROLLER2_IMR_ILLEGAL_WRITE_ENABLED (0x00000002) - -/* - * QSPI_CHIP_SELECT register offset - * - * The QSPI_CHIP_SELECT register is used to issue chip select - */ -#define ALTERA_QSPI_CHIP_SELECT_REG (0x18) - -/* - * QSPI_CHIP_SELECT register access macros - */ -#define IOADDR_ALTERA_QSPI_CHIP_SELECT(base) \ - __IO_CALC_ADDRESS_DYNAMIC(base, ALTERA_QSPI_CHIP_SELECT_REG) - -#define IOWR_ALTERA_QSPI_CHIP_SELECT(base, data) \ - IOWR_32DIRECT(base, ALTERA_QSPI_CHIP_SELECT_REG, data) - -/* - * QSPI_CHIP_SELECT register description macros - */ -#define ALTERA_QSPI_CHIP1_SELECT (0x00000001) -#define ALTERA_QSPI_CHIP2_SELECT (0x00000002) -#define ALTERA_QSPI_CHIP3_SELECT (0x00000003) - -#endif /* __ALTERA_QSPI_CONTROLLER2_REGS_H__ */ diff --git a/ext/hal/altera/drivers/altera_msgdma/HAL/inc/altera_msgdma.h b/ext/hal/altera/drivers/altera_msgdma/HAL/inc/altera_msgdma.h deleted file mode 100644 index aa02a2c848..0000000000 --- a/ext/hal/altera/drivers/altera_msgdma/HAL/inc/altera_msgdma.h +++ /dev/null @@ -1,501 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2014 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALTERA_MSGDMA_H__ -#define __ALTERA_MSGDMA_H__ - -#include -#include - -#include "sys/alt_dev.h" -#include "alt_types.h" -#include "altera_msgdma_csr_regs.h" -#include "altera_msgdma_descriptor_regs.h" -#include "altera_msgdma_response_regs.h" -#include "altera_msgdma_prefetcher_regs.h" -#include "os/alt_sem.h" -#include "os/alt_flag.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * Helper struct to have easy access to hi/low values from a 64 bit value. - * Useful when having to write prefetcher/descriptor 64 bit addresses. - */ -typedef union { - alt_u64 u64; - alt_u32 u32[2]; -} msgdma_addr64; - -/* - * To ensure that a descriptor is created without spaces between the structure - * members, we call upon GCC's ability to pack to a byte-aligned boundary. - * Additionally, msgdma requires the descriptors to be aligned to a 16 byte - * boundary. - */ -#define alt_msgdma_standard_descriptor_packed \ - __attribute__ ((packed, aligned(16))) -#define alt_msgdma_extended_descriptor_packed \ - __attribute__ ((packed, aligned(32))) -#define alt_msgdma_prefetcher_standard_descriptor_packed \ - __attribute__ ((packed, aligned(32))) -#define alt_msgdma_prefetcher_extended_descriptor_packed \ - __attribute__ ((packed, aligned(64))) -#define alt_msgdma_response_packed __attribute__ ((packed, aligned(4))) - -/* - * The function alt_find_dev() is used to search the device list "list" to - * locate a device named "name". If a match is found, then a pointer to the - * device is returned, otherwise NULL is returned. - */ -extern alt_dev* alt_find_dev (const char* name, alt_llist* list); - -/* Callback routine type definition */ -typedef void (*alt_msgdma_callback)(void *context); - -/* use this structure if you haven't enabled the enhanced features */ -typedef struct { - alt_u32 *read_address; - alt_u32 *write_address; - alt_u32 transfer_length; - alt_u32 control; -} alt_msgdma_standard_descriptor_packed alt_msgdma_standard_descriptor; - -/* use this structure if you have enabled the enhanced features (only the - * elements enabled in hardware will be used) - */ -typedef struct { - alt_u32 *read_address_low; - alt_u32 *write_address_low; - alt_u32 transfer_length; - alt_u16 sequence_number; - alt_u8 read_burst_count; - alt_u8 write_burst_count; - alt_u16 read_stride; - alt_u16 write_stride; - alt_u32 *read_address_high; - alt_u32 *write_address_high; - alt_u32 control; -} alt_msgdma_extended_descriptor_packed alt_msgdma_extended_descriptor; - - -/* Prefetcher Descriptors need to be different than standard dispatcher - * descriptors use this structure if you haven't enabled the enhanced - * features - */ -typedef struct { - alt_u32 read_address; - alt_u32 write_address; - alt_u32 transfer_length; - alt_u32 next_desc_ptr; - alt_u32 bytes_transfered; - alt_u16 status; - alt_u16 _pad1_rsvd; - alt_u32 _pad2_rsvd; - alt_u32 control; -} alt_msgdma_prefetcher_standard_descriptor_packed alt_msgdma_prefetcher_standard_descriptor; - -/* use this structure if you have enabled the enhanced features (only the elements -enabled in hardware will be used) */ -typedef struct { - alt_u32 read_address_low; - alt_u32 write_address_low; - alt_u32 transfer_length; - alt_u32 next_desc_ptr_low; - alt_u32 bytes_transfered; - alt_u16 status; - alt_u16 _pad1_rsvd; - alt_u32 _pad2_rsvd; - alt_u16 sequence_number; - alt_u8 read_burst_count; - alt_u8 write_burst_count; - alt_u16 read_stride; - alt_u16 write_stride; - alt_u32 read_address_high; - alt_u32 write_address_high; - alt_u32 next_desc_ptr_high; - alt_u32 _pad3_rsvd[3]; - alt_u32 control; -} alt_msgdma_prefetcher_extended_descriptor_packed alt_msgdma_prefetcher_extended_descriptor; - - -/* msgdma device structure */ -typedef struct alt_msgdma_dev -{ - /* Device linked-list entry */ - alt_llist llist; - /* Name of msgdma in Qsys system */ - const char *name; - /* Base address of control and status register */ - alt_u32 *csr_base; - /* Base address of the descriptor slave port */ - alt_u32 *descriptor_base; - /* Base address of the response register */ - alt_u32 *response_base; - /* Base address of the prefetcher register */ - alt_u32 *prefetcher_base; - /* device IRQ controller ID */ - alt_u32 irq_controller_ID; - /* device IRQ ID */ - alt_u32 irq_ID; - /* FIFO size to store descriptor count, - { 8, 16, 32, 64,default:128, 256, 512, 1024 } */ - alt_u32 descriptor_fifo_depth; - /* FIFO size to store response count */ - alt_u32 response_fifo_depth; - /* Callback routine pointer */ - alt_msgdma_callback callback; - /* Callback context pointer */ - void *callback_context; - /* user define control setting during interrupt registering*/ - alt_u32 control; - /* Enable burst transfer */ - alt_u8 burst_enable; - /* Enable burst wrapping */ - alt_u8 burst_wrapping_support; - /* Depth of the internal data path FIFO*/ - alt_u32 data_fifo_depth; - /* Data path Width. This parameter affect both read - master and write master data width */ - alt_u32 data_width; - /* Maximum burst count*/ - alt_u32 max_burst_count; - /* Maximum transfer length*/ - alt_u32 max_byte; - /* Maximum stride count */ - alt_u64 max_stride; - /* Enable dynamic burst programming*/ - alt_u8 programmable_burst_enable; - /* Enable stride addressing */ - alt_u8 stride_enable; - /* Supported transaction type */ - const char *transfer_type; - /* Extended feature support enable "1"-enable "0"-disable */ - alt_u8 enhanced_features; - /* Enable response port "0"-memory-mapped, "1"-streaming, "2"-disable */ - alt_u8 response_port; - /* Prefetcher enabled "0"-disabled, "1"-enabled*/ - alt_u8 prefetcher_enable; - /* Semaphore used to control access registers - in multi-threaded mode */ - ALT_SEM (regs_lock) -} alt_msgdma_dev; - - - -/******************************************************************************* - * Public API - ******************************************************************************/ -alt_msgdma_dev* alt_msgdma_open (const char* name); - -void alt_msgdma_register_callback( - alt_msgdma_dev *dev, - alt_msgdma_callback callback, - alt_u32 control, - void *context); - -int alt_msgdma_standard_descriptor_async_transfer( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *desc); - -int alt_msgdma_extended_descriptor_async_transfer( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *desc); - -int alt_msgdma_construct_standard_mm_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 *write_address, - alt_u32 length, - alt_u32 control); - -int alt_msgdma_construct_standard_st_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *descriptor, - alt_u32 *write_address, - alt_u32 length, - alt_u32 control); - -int alt_msgdma_construct_standard_mm_to_st_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 length, - alt_u32 control); - -int alt_msgdma_construct_extended_st_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *descriptor, - alt_u32 *write_address, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 write_burst_count, - alt_u16 write_stride); - -int alt_msgdma_construct_extended_mm_to_st_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 read_burst_count, - alt_u16 read_stride); - -int alt_msgdma_construct_extended_mm_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 *write_address, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 read_burst_count, - alt_u8 write_burst_count, - alt_u16 read_stride, - alt_u16 write_stride); - -int alt_msgdma_standard_descriptor_sync_transfer( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *desc); - -int alt_msgdma_extended_descriptor_sync_transfer( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *desc); - -int alt_msgdma_standard_descriptor_sync_transfer( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *desc); - -/***************** MSGDMA PREFETCHER PUBLIC APIs ******************/ -int alt_msgdma_construct_prefetcher_standard_mm_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_standard_descriptor *descriptor, - alt_u32 read_address, - alt_u32 write_address, - alt_u32 length, - alt_u32 control); - -int alt_msgdma_construct_prefetcher_standard_st_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_standard_descriptor *descriptor, - alt_u32 write_address, - alt_u32 length, - alt_u32 control); - -int alt_msgdma_construct_prefetcher_standard_mm_to_st_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_standard_descriptor *descriptor, - alt_u32 read_address, - alt_u32 length, - alt_u32 control); - -int alt_msgdma_construct_prefetcher_extended_st_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_extended_descriptor *descriptor, - alt_u32 write_address_high, - alt_u32 write_address_low, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 write_burst_count, - alt_u16 write_stride); - -int alt_msgdma_construct_prefetcher_extended_mm_to_st_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_extended_descriptor *descriptor, - alt_u32 read_address_high, - alt_u32 read_address_low, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 read_burst_count, - alt_u16 read_stride); - -int alt_msgdma_construct_prefetcher_extended_mm_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_extended_descriptor *descriptor, - alt_u32 read_address_high, - alt_u32 read_address_low, - alt_u32 write_address_high, - alt_u32 write_address_low, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 read_burst_count, - alt_u8 write_burst_count, - alt_u16 read_stride, - alt_u16 write_stride); - -int alt_msgdma_prefetcher_add_standard_desc_to_list ( - alt_msgdma_prefetcher_standard_descriptor** list, - alt_msgdma_prefetcher_standard_descriptor* descriptor); - -int alt_msgdma_prefetcher_add_extended_desc_to_list ( - alt_msgdma_prefetcher_extended_descriptor** list, - alt_msgdma_prefetcher_extended_descriptor* descriptor); - -int alt_msgdma_start_prefetcher_with_std_desc_list ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_standard_descriptor *list, - alt_u8 park_mode_en, - alt_u8 poll_en); - -int alt_msgdma_start_prefetcher_with_extd_desc_list ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_extended_descriptor *list, - alt_u8 park_mode_en, - alt_u8 poll_en); - -int alt_msgdma_prefetcher_set_std_list_own_by_hw_bits ( - alt_msgdma_prefetcher_standard_descriptor *list); -int alt_msgdma_prefetcher_set_extd_list_own_by_hw_bits ( - alt_msgdma_prefetcher_extended_descriptor *list); - -void alt_msgdma_init (alt_msgdma_dev *dev, alt_u32 ic_id, alt_u32 irq); - -/* HAL initialization macros */ - -/*Depth of internal data path FIFO.STRIDE_ENABLE - * ALTERA_MSGDMA_INSTANCE is the macro used by alt_sys_init() to - * allocate any per device memory that may be required. - */ -#define ALTERA_MSGDMA_CSR_DESCRIPTOR_SLAVE_RESPONSE_INSTANCE(name, csr_if, desc_if, resp_if, dev) \ -static alt_msgdma_dev dev = \ -{ \ - ALT_LLIST_ENTRY, \ - name##_CSR_NAME, \ - ((alt_u32 *)(csr_if##_BASE)), \ - ((alt_u32 *)(desc_if##_BASE)), \ - ((alt_u32 *)(resp_if##_BASE)), \ - ((alt_u32 *)(0)), \ - ((alt_u32 )name##_CSR_IRQ_INTERRUPT_CONTROLLER_ID), \ - ((alt_u32 )name##_CSR_IRQ), \ - ((alt_u32 )desc_if##_DESCRIPTOR_FIFO_DEPTH), \ - ((alt_u32 )resp_if##_DESCRIPTOR_FIFO_DEPTH * 2), \ - ((void *) 0x0), \ - ((void *) 0x0), \ - ((alt_u32) 0x0), \ - ((alt_u8) csr_if##_BURST_ENABLE), \ - ((alt_u8) csr_if##_BURST_WRAPPING_SUPPORT), \ - ((alt_u32) csr_if##_DATA_FIFO_DEPTH), \ - ((alt_u32) csr_if##_DATA_WIDTH), \ - ((alt_u32) csr_if##_MAX_BURST_COUNT), \ - ((alt_u32) csr_if##_MAX_BYTE), \ - ((alt_u64) csr_if##_MAX_STRIDE), \ - ((alt_u8) csr_if##_PROGRAMMABLE_BURST_ENABLE), \ - ((alt_u8) csr_if##_STRIDE_ENABLE), \ - csr_if##_TRANSFER_TYPE, \ - ((alt_u8) csr_if##_ENHANCED_FEATURES), \ - ((alt_u8) csr_if##_RESPONSE_PORT), \ - ((alt_u8) csr_if##_PREFETCHER_ENABLE) \ -}; - -#define ALTERA_MSGDMA_CSR_DESCRIPTOR_SLAVE_INSTANCE(name, csr_if, desc_if, dev) \ -static alt_msgdma_dev dev = \ -{ \ - ALT_LLIST_ENTRY, \ - name##_CSR_NAME, \ - ((alt_u32 *)(csr_if##_BASE)), \ - ((alt_u32 *)(desc_if##_BASE)), \ - ((alt_u32 *)(0)), \ - ((alt_u32 *)(0)), \ - ((alt_u32 )name##_CSR_IRQ_INTERRUPT_CONTROLLER_ID), \ - ((alt_u32 )name##_CSR_IRQ), \ - ((alt_u32 )desc_if##_DESCRIPTOR_FIFO_DEPTH), \ - ((alt_u32) 0x0), \ - ((void *) 0x0), \ - ((void *) 0x0), \ - ((alt_u32) 0x0), \ - ((alt_u8) csr_if##_BURST_ENABLE), \ - ((alt_u8) csr_if##_BURST_WRAPPING_SUPPORT), \ - ((alt_u32) csr_if##_DATA_FIFO_DEPTH), \ - ((alt_u32) csr_if##_DATA_WIDTH), \ - ((alt_u32) csr_if##_MAX_BURST_COUNT), \ - ((alt_u32) csr_if##_MAX_BYTE), \ - ((alt_u64) csr_if##_MAX_STRIDE), \ - ((alt_u8) csr_if##_PROGRAMMABLE_BURST_ENABLE), \ - ((alt_u8) csr_if##_STRIDE_ENABLE), \ - csr_if##_TRANSFER_TYPE, \ - ((alt_u8) csr_if##_ENHANCED_FEATURES), \ - ((alt_u8) csr_if##_RESPONSE_PORT), \ - ((alt_u8) csr_if##_PREFETCHER_ENABLE) \ -}; - -/* - * New Interface for Prefetcher 15/6/2015. - */ -#define ALTERA_MSGDMA_CSR_PREFETCHER_CSR_INSTANCE(name, csr_if, pref_if, dev) \ -static alt_msgdma_dev dev = \ -{ \ - ALT_LLIST_ENTRY, \ - name##_CSR_NAME, \ - ((alt_u32 *)(csr_if##_BASE)), \ - ((alt_u32 *)(0)), \ - ((alt_u32 *)(0)), \ - ((alt_u32 *)(pref_if##_BASE)), \ - ((alt_u32 )name##_PREFETCHER_CSR_IRQ_INTERRUPT_CONTROLLER_ID), \ - ((alt_u32 )name##_PREFETCHER_CSR_IRQ), \ - ((alt_u32 )(0)), \ - ((alt_u32) 0x0), \ - ((void *) 0x0), \ - ((void *) 0x0), \ - ((alt_u32) 0x0), \ - ((alt_u8) csr_if##_BURST_ENABLE), \ - ((alt_u8) csr_if##_BURST_WRAPPING_SUPPORT), \ - ((alt_u32) csr_if##_DATA_FIFO_DEPTH), \ - ((alt_u32) csr_if##_DATA_WIDTH), \ - ((alt_u32) csr_if##_MAX_BURST_COUNT), \ - ((alt_u32) csr_if##_MAX_BYTE), \ - ((alt_u64) csr_if##_MAX_STRIDE), \ - ((alt_u8) csr_if##_PROGRAMMABLE_BURST_ENABLE), \ - ((alt_u8) csr_if##_STRIDE_ENABLE), \ - csr_if##_TRANSFER_TYPE, \ - ((alt_u8) csr_if##_ENHANCED_FEATURES), \ - ((alt_u8) csr_if##_RESPONSE_PORT), \ - ((alt_u8) csr_if##_PREFETCHER_ENABLE) \ -}; - - -/* - * The macro ALTERA_MSGDMA_INIT is called by the auto-generated function - * alt_sys_init() to initialize a given device instance. - */ -#define ALTERA_MSGDMA_INIT(name, dev) \ - alt_msgdma_init(&dev, dev.irq_controller_ID, dev.irq_ID); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALTERA_MSGDMA_H__ */ diff --git a/ext/hal/altera/drivers/altera_msgdma/HAL/src/CMakeLists.txt b/ext/hal/altera/drivers/altera_msgdma/HAL/src/CMakeLists.txt deleted file mode 100644 index e89cc66a59..0000000000 --- a/ext/hal/altera/drivers/altera_msgdma/HAL/src/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -zephyr_sources(altera_msgdma.c) diff --git a/ext/hal/altera/drivers/altera_msgdma/HAL/src/altera_msgdma.c b/ext/hal/altera/drivers/altera_msgdma/HAL/src/altera_msgdma.c deleted file mode 100644 index 5a4192016c..0000000000 --- a/ext/hal/altera/drivers/altera_msgdma/HAL/src/altera_msgdma.c +++ /dev/null @@ -1,1726 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2014 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ -#include -#include -#include -#include -#include "altera_msgdma_descriptor_regs.h" -#include "altera_msgdma_csr_regs.h" -#include "altera_msgdma_response_regs.h" -#include "io.h" -#include "altera_msgdma.h" -#include "priv/alt_busy_sleep.h" -#include "sys/alt_errno.h" -#include "sys/alt_irq.h" -#include "sys/alt_stdio.h" - - - - -/******************************************************************************* - * Private API - ******************************************************************************/ -static int alt_msgdma_write_standard_descriptor ( - alt_u32 *csr_base, - alt_u32 *descriptor_base, - alt_msgdma_standard_descriptor *descriptor); -static int alt_msgdma_write_extended_descriptor ( - alt_u32 *csr_base, - alt_u32 *descriptor_base, - alt_msgdma_extended_descriptor *descriptor); -static void alt_msgdma_irq(void *context); -static int alt_msgdma_construct_standard_descriptor( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 *write_address, - alt_u32 length, - alt_u32 control); -static int alt_msgdma_construct_extended_descriptor( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 *write_address, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 read_burst_count, - alt_u8 write_burst_count, - alt_u16 read_stride, - alt_u16 write_stride); -static int alt_msgdma_descriptor_async_transfer ( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *standard_desc, - alt_msgdma_extended_descriptor *extended_desc); -static int alt_msgdma_descriptor_sync_transfer ( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *standard_desc, - alt_msgdma_extended_descriptor *extended_desc); -/* The list of registered msgdma components */ -ALT_LLIST_HEAD(alt_msgdma_list); - -/* - * Functions for writing descriptor structure to the dispatcher. If you disable - * some of the extended features in the hardware then you should pass in 0 for - * that particular descriptor element. These disabled elements will not be - * buffered by the dispatcher block. - * - * This function is non-blocking and will return an error code if there is no - * room to write another descriptor to the dispatcher. It is recommended to call - * 'read_descriptor_buffer_full' and make sure it returns '0' before calling - * this function. - */ -static int alt_msgdma_write_standard_descriptor ( - alt_u32 *csr_base, - alt_u32 *descriptor_base, - alt_msgdma_standard_descriptor *descriptor) -{ - if (0 != (IORD_ALTERA_MSGDMA_CSR_STATUS(csr_base) & - ALTERA_MSGDMA_CSR_DESCRIPTOR_BUFFER_FULL_MASK)) - { - /*at least one descriptor buffer is full, returning so that this function - is non-blocking*/ - return -ENOSPC; - } - - IOWR_ALTERA_MSGDMA_DESCRIPTOR_READ_ADDRESS(descriptor_base, - (alt_u32)descriptor->read_address); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_WRITE_ADDRESS(descriptor_base, - ( alt_u32)descriptor->write_address); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_LENGTH(descriptor_base, - descriptor->transfer_length); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_CONTROL_STANDARD(descriptor_base, - descriptor->control); - return 0; -} - -/* - * This function is used for writing extended descriptors to the dispatcher. - It handles only 32-bit descriptors. - */ -static int alt_msgdma_write_extended_descriptor ( - alt_u32 *csr_base, - alt_u32 *descriptor_base, - alt_msgdma_extended_descriptor *descriptor) -{ - if (0 != (IORD_ALTERA_MSGDMA_CSR_STATUS(csr_base) & - ALTERA_MSGDMA_CSR_DESCRIPTOR_BUFFER_FULL_MASK)) - { - /*at least one descriptor buffer is full, returning so that this function - is non-blocking*/ - return -ENOSPC; - } - - IOWR_ALTERA_MSGDMA_DESCRIPTOR_READ_ADDRESS( - descriptor_base, - (alt_u32)descriptor->read_address_low); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_WRITE_ADDRESS( - descriptor_base, - (alt_u32)descriptor->write_address_low); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_LENGTH( - descriptor_base, - descriptor->transfer_length); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_SEQUENCE_NUMBER( - descriptor_base, - descriptor->sequence_number); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_READ_BURST( - descriptor_base, - descriptor->read_burst_count); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_WRITE_BURST( - descriptor_base, - descriptor->write_burst_count); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_READ_STRIDE( - descriptor_base, - descriptor->read_stride); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_WRITE_STRIDE( - descriptor_base, - descriptor->write_stride); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_READ_ADDRESS_HIGH(descriptor_base, 0); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_WRITE_ADDRESS_HIGH(descriptor_base, 0); - IOWR_ALTERA_MSGDMA_DESCRIPTOR_CONTROL_ENHANCED( - descriptor_base, - descriptor->control); - return 0; -} - -/* - * alt_msgdma_irq() - * - * Interrupt handler for the Modular Scatter-Gather DMA controller. - */ -static void alt_msgdma_irq(void *context) -{ - alt_msgdma_dev *dev = (alt_msgdma_dev *) context; - alt_irq_context cpu_sr; - alt_u32 temporary_control; - - - /* disable global interrupt*/ - if (dev->prefetcher_enable) - { - temporary_control = - IORD_ALT_MSGDMA_PREFETCHER_CONTROL(dev->prefetcher_base) - & ALT_MSGDMA_PREFETCHER_CTRL_GLOBAL_INTR_EN_CLR_MASK; - - IOWR_ALT_MSGDMA_PREFETCHER_CONTROL(dev->prefetcher_base, - temporary_control); - - /* clear the IRQ status- W1C */ - IOWR_ALT_MSGDMA_PREFETCHER_STATUS(dev->prefetcher_base, - ALT_MSGDMA_PREFETCHER_STATUS_IRQ_SET_MASK); - } - else - { - temporary_control = IORD_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base) - & (~ALTERA_MSGDMA_CSR_GLOBAL_INTERRUPT_MASK); - - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, temporary_control); - /* clear the IRQ status */ - IOWR_ALTERA_MSGDMA_CSR_STATUS(dev->csr_base, - ALTERA_MSGDMA_CSR_IRQ_SET_MASK); - } - - /* - * Other interrupts are explicitly disabled if callbacks - * are registered because there is no guarantee that they are - * pre-emption-safe. This allows the driver to support - * interrupt pre-emption. - */ - if(dev->callback) - { - cpu_sr = alt_irq_disable_all(); - dev->callback (dev->callback_context); - alt_irq_enable_all(cpu_sr); - } - - /* enable global interrupt */ - if (dev->prefetcher_enable) - { - temporary_control = - IORD_ALT_MSGDMA_PREFETCHER_CONTROL(dev->prefetcher_base) - | ALT_MSGDMA_PREFETCHER_CTRL_GLOBAL_INTR_EN_SET_MASK; - - IOWR_ALT_MSGDMA_PREFETCHER_CONTROL(dev->prefetcher_base, - temporary_control); - } - else - { - temporary_control = IORD_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base) - | (ALTERA_MSGDMA_CSR_GLOBAL_INTERRUPT_MASK); - - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, temporary_control); - } - - return; -} -/* - * Helper functions for constructing mm_to_st, st_to_mm, mm_to_mm standard - * descriptors. Unnecessary elements are set to 0 for completeness and will be - * ignored by the hardware. - * Returns: - * - status: return 0 (success) - * return -EINVAL (invalid argument, could be due to argument which - * has larger value than hardware setting value) - */ -static int alt_msgdma_construct_standard_descriptor( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 *write_address, - alt_u32 length, - alt_u32 control) -{ - if(dev->max_byte < length || - dev->enhanced_features != 0 - ) - { - return -EINVAL; - } - descriptor->read_address = read_address; - descriptor->write_address = write_address; - descriptor->transfer_length = length; - descriptor->control = control | ALTERA_MSGDMA_DESCRIPTOR_CONTROL_GO_MASK; - - return 0; -} - -/* - * Helper functions for constructing mm_to_st, st_to_mm, mm_to_mm extended - * descriptors. Unnecessary elements are set to 0 for completeness and will be - * ignored by the hardware. - * Returns: - * - status: return 0 (success) - * return -EINVAL (invalid argument, could be due to argument which - * has larger value than hardware setting value) - */ -static int alt_msgdma_construct_extended_descriptor( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 *write_address, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 read_burst_count, - alt_u8 write_burst_count, - alt_u16 read_stride, - alt_u16 write_stride) -{ - if(dev->max_byte < length || - dev->max_stride < read_stride || - dev->max_stride < write_stride || - dev->enhanced_features != 1 - ) - { - return -EINVAL; - } - - descriptor->read_address_low = read_address; - descriptor->write_address_low = write_address; - descriptor->transfer_length = length; - descriptor->sequence_number = sequence_number; - descriptor->read_burst_count = read_burst_count; - descriptor->write_burst_count = write_burst_count; - descriptor->read_stride = read_stride; - descriptor->write_stride = write_stride; - descriptor->read_address_high = NULL; - descriptor->write_address_high = NULL; - descriptor->control = control | ALTERA_MSGDMA_DESCRIPTOR_CONTROL_GO_MASK; - - return 0 ; - -} - -/* - * Helper functions for descriptor in async transfer. - * Arguments:# This driver supports HAL types - * - *dev: Pointer to msgdma device (instance) structure. - * - *standard_desc: Pointer to single standard descriptor. - * - *extended_desc: Pointer to single extended descriptor. - * - *note: Either one of both *standard_desc and *extended_desc must - * be assigned with NULL, another with proper pointer value. - * Failing to do so can cause the function return with "-EPERM " - * - * If a callback routine has been previously registered with this - * particular msgdma controller, transfer will be set up to enable interrupt - * generation. It is the responsibility of the application developer to check - * source interruption, status completion and creating suitable interrupt - * handling. Note: "stop on error" of CSR control register is always masking - * within this function. The CSR control can be set by user through calling - * "alt_register_callback" by passing user used defined control setting. - * - * Returns: - * 0 -> success - * -ENOSPC -> FIFO descriptor buffer is full - * -EPERM -> operation not permitted due to descriptor type conflict - * -ETIME -> Time out and skipping the looping after 5 msec. - */ -static int alt_msgdma_descriptor_async_transfer ( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *standard_desc, - alt_msgdma_extended_descriptor *extended_desc) -{ - alt_u32 control = 0; - alt_irq_context context = 0; - alt_u16 counter = 0; - alt_u32 fifo_read_fill_level = ( - IORD_ALTERA_MSGDMA_CSR_DESCRIPTOR_FILL_LEVEL(dev->csr_base) & - ALTERA_MSGDMA_CSR_READ_FILL_LEVEL_MASK) >> - ALTERA_MSGDMA_CSR_READ_FILL_LEVEL_OFFSET; - alt_u32 fifo_write_fill_level = ( - IORD_ALTERA_MSGDMA_CSR_DESCRIPTOR_FILL_LEVEL(dev->csr_base) & - ALTERA_MSGDMA_CSR_WRITE_FILL_LEVEL_MASK) >> - ALTERA_MSGDMA_CSR_WRITE_FILL_LEVEL_OFFSET; - - /* Return with error immediately if one of read/write buffer is full */ - if((dev->descriptor_fifo_depth <= fifo_write_fill_level) || - (dev->descriptor_fifo_depth <= fifo_read_fill_level)) - { - /*at least one write or read FIFO descriptor buffer is full, - returning so that this function is non-blocking*/ - return -ENOSPC; - } - - /* - * When running in a multi threaded environment, obtain the "regs_lock" - * semaphore. This ensures that accessing registers is thread-safe. - */ - ALT_SEM_PEND (dev->regs_lock, 0); - - /* Stop the msgdma dispatcher from issuing more descriptors to the - read or write masters */ - /* stop issuing more descriptors */ - control = ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_MASK; - /* making sure the read-modify-write below can't be pre-empted */ - context = alt_irq_disable_all(); - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, control); - /* - * Clear any (previous) status register information - * that might occlude our error checking later. - */ - IOWR_ALTERA_MSGDMA_CSR_STATUS( - dev->csr_base, - IORD_ALTERA_MSGDMA_CSR_STATUS(dev->csr_base)); - alt_irq_enable_all(context); - - if (NULL != standard_desc && NULL == extended_desc) - { - /*writing descriptor structure to the dispatcher, wait until descriptor - write is succeed*/ - while(0 != alt_msgdma_write_standard_descriptor ( - dev->csr_base, dev->descriptor_base, standard_desc)) - { - alt_busy_sleep(1); /* delay 1us */ - if(5000 <= counter) /* time_out if waiting longer than 5 msec */ - { - alt_printf("time out after 5 msec while waiting" - " free FIFO buffer for storing standard descriptor\n"); - - /* - * Now that access to the registers is complete, release the - * registers semaphore so that other threads can access the - * registers. - */ - ALT_SEM_POST (dev->regs_lock); - - return -ETIME; - } - counter++; - } - } - else if (NULL == standard_desc && NULL != extended_desc) - { - counter = 0; /* reset counter */ - /*writing descriptor structure to the dispatcher, wait until descriptor - write is succeed*/ - while(0 != alt_msgdma_write_extended_descriptor ( - dev->csr_base, - dev->descriptor_base, - extended_desc)) - { - alt_busy_sleep(1); /* delay 1us */ - if(5000 <= counter) /* time_out if waiting longer than 5 msec */ - { - alt_printf("time out after 5 msec while waiting free FIFO buffer" - " for storing extended descriptor\n"); - /* - * Now that access to the registers is complete, release the - * registers semaphore so that other threads can access the - * registers. - */ - ALT_SEM_POST (dev->regs_lock); - - return -ETIME; - } - counter++; - } - } - else - { - /* - * Now that access to the registers is complete, release the registers - * semaphore so that other threads can access the registers. - */ - ALT_SEM_POST (dev->regs_lock); - - /* operation not permitted due to descriptor type conflict */ - return -EPERM; - } - - /* - * If a callback routine has been previously registered which will be - * called from the msgdma ISR. Set up controller to: - * - Run - * - Stop on an error with any particular descriptor - */ - if(dev->callback) - { - - control |= (dev->control | - ALTERA_MSGDMA_CSR_STOP_ON_ERROR_MASK | - ALTERA_MSGDMA_CSR_GLOBAL_INTERRUPT_MASK ); - control &= (~ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_MASK); - /* making sure the read-modify-write below can't be pre-empted */ - context = alt_irq_disable_all(); - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, control); - alt_irq_enable_all(context); - } - /* - * No callback has been registered. Set up controller to: - * - Run - * - Stop on an error with any particular descriptor - * - Disable interrupt generation - */ - else - { - control |= (dev->control | - ALTERA_MSGDMA_CSR_STOP_ON_ERROR_MASK ); - control &= (~ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_MASK) & - (~ALTERA_MSGDMA_CSR_GLOBAL_INTERRUPT_MASK); - /* making sure the read-modify-write below can't be pre-empted */ - context = alt_irq_disable_all(); - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, control); - alt_irq_enable_all(context); - } - - /* - * Now that access to the registers is complete, release the registers - * semaphore so that other threads can access the registers. - */ - ALT_SEM_POST (dev->regs_lock); - - return 0; -} - -/* - * Helper functions for descriptor in sync transfer. - * Arguments: - * - *dev: Pointer to msgdma device (instance) structure. - * - *standard_desc: Pointer to single standard descriptor. - * - *extended_desc: Pointer to single extended descriptor. - * - * Note: Either one of both *standard_desc and *extended_desc must - * be assigned with NULL, another with proper pointer value. - * Failing to do so can cause the function return with "-EPERM " - * - * "stop on error" of CSR control register is always being masked and interrupt - * is always disabled within this function. - * The CSR control can be set by user through calling "alt_register_callback" - * with passing user defined control setting. - * - * Returns: - * 0 -> success - * error -> errors or conditions causing msgdma stop issuing commands to masters. - * check the bit set in the error with CSR status register. - * -EPERM -> operation not permitted due to descriptor type conflict - * -ETIME -> Time out and skipping the looping after 5 msec. - */ -static int alt_msgdma_descriptor_sync_transfer ( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *standard_desc, - alt_msgdma_extended_descriptor *extended_desc) -{ - alt_u32 control=0; - alt_irq_context context=0; - alt_u32 csr_status = 0; - alt_u16 counter = 0; - alt_u32 fifo_read_fill_level = ( - IORD_ALTERA_MSGDMA_CSR_DESCRIPTOR_FILL_LEVEL(dev->csr_base) & - ALTERA_MSGDMA_CSR_READ_FILL_LEVEL_MASK) >> - ALTERA_MSGDMA_CSR_READ_FILL_LEVEL_OFFSET; - alt_u32 fifo_write_fill_level = ( - IORD_ALTERA_MSGDMA_CSR_DESCRIPTOR_FILL_LEVEL(dev->csr_base) & - ALTERA_MSGDMA_CSR_WRITE_FILL_LEVEL_MASK) >> - ALTERA_MSGDMA_CSR_WRITE_FILL_LEVEL_OFFSET; - alt_u32 error = ALTERA_MSGDMA_CSR_STOPPED_ON_ERROR_MASK | - ALTERA_MSGDMA_CSR_STOPPED_ON_EARLY_TERMINATION_MASK | - ALTERA_MSGDMA_CSR_STOP_STATE_MASK | - ALTERA_MSGDMA_CSR_RESET_STATE_MASK; - - /* Wait for available FIFO buffer to store new descriptor*/ - while ((dev->descriptor_fifo_depth <= fifo_write_fill_level) || - (dev->descriptor_fifo_depth <= fifo_read_fill_level)) - { - alt_busy_sleep(1); /* delay 1us */ - if(5000 <= counter) /* time_out if waiting longer than 5 msec */ - { - alt_printf("time out after 5 msec while waiting free FIFO buffer" - " for storing descriptor\n"); - return -ETIME; - } - counter++; - fifo_read_fill_level = ( - IORD_ALTERA_MSGDMA_CSR_DESCRIPTOR_FILL_LEVEL(dev->csr_base) & - ALTERA_MSGDMA_CSR_READ_FILL_LEVEL_MASK) >> - ALTERA_MSGDMA_CSR_READ_FILL_LEVEL_OFFSET; - fifo_write_fill_level = ( - IORD_ALTERA_MSGDMA_CSR_DESCRIPTOR_FILL_LEVEL(dev->csr_base) & - ALTERA_MSGDMA_CSR_WRITE_FILL_LEVEL_MASK) >> - ALTERA_MSGDMA_CSR_WRITE_FILL_LEVEL_OFFSET; - } - - /* - * When running in a multi threaded environment, obtain the "regs_lock" - * semaphore. This ensures that accessing registers is thread-safe. - */ - ALT_SEM_PEND (dev->regs_lock, 0); - - /* Stop the msgdma dispatcher from issuing more descriptors to the - read or write masters */ - /* making sure the read-modify-write below can't be pre-empted */ - context = alt_irq_disable_all(); - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, - ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_MASK); - /* - * Clear any (previous) status register information - * that might occlude our error checking later. - */ - IOWR_ALTERA_MSGDMA_CSR_STATUS( - dev->csr_base, - IORD_ALTERA_MSGDMA_CSR_STATUS(dev->csr_base)); - - if (NULL != standard_desc && NULL == extended_desc) - { - counter = 0; /* reset counter */ - /*writing descriptor structure to the dispatcher, wait until descriptor - write is succeed*/ - while(0 != alt_msgdma_write_standard_descriptor ( - dev->csr_base, dev->descriptor_base, standard_desc)) - { - alt_busy_sleep(1); /* delay 1us */ - if(5000 <= counter) /* time_out if waiting longer than 5 msec */ - { - alt_printf("time out after 5 msec while writing standard" - " descriptor to FIFO\n"); - - /* - * Now that access to the registers is complete, release the - * registers semaphore so that other threads can access the - * registers. - */ - ALT_SEM_POST (dev->regs_lock); - - return -ETIME; - } - counter++; - } - } - else if (NULL == standard_desc && NULL != extended_desc) - { - counter = 0; /* reset counter */ - /*writing descriptor structure to the dispatcher, wait until descriptor - write is succeed*/ - while(0 != alt_msgdma_write_extended_descriptor ( - dev->csr_base, dev->descriptor_base, extended_desc)) - { - alt_busy_sleep(1); /* delay 1us */ - if(5000 <= counter) /* time_out if waiting longer than 5 msec */ - { - alt_printf("time out after 5 msec while writing extended" - " descriptor to FIFO\n"); - - /* - * Now that access to the registers is complete, release the - * registers semaphore so that other threads can access the - * registers. - */ - ALT_SEM_POST (dev->regs_lock); - - return -ETIME; - } - counter++; - } - } - else - { - /* - * Now that access to the registers is complete, release the registers - * semaphore so that other threads can access the registers. - */ - ALT_SEM_POST (dev->regs_lock); - - /* operation not permitted due to descriptor type conflict */ - return -EPERM; - } - - /* - * Set up msgdma controller to: - * - Disable interrupt generation - * - Run once a valid descriptor is written to controller - * - Stop on an error with any particular descriptor - */ - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, - (dev->control | - ALTERA_MSGDMA_CSR_STOP_ON_ERROR_MASK ) & - (~ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_MASK) & - (~ALTERA_MSGDMA_CSR_GLOBAL_INTERRUPT_MASK)) ; - - alt_irq_enable_all(context); - - counter = 0; /* reset counter */ - - csr_status = IORD_ALTERA_MSGDMA_CSR_STATUS(dev->csr_base); - - /* Wait for any pending transfers to complete or checking any errors or - conditions causing descriptor to stop dispatching */ - while (!(csr_status & error) && (csr_status & ALTERA_MSGDMA_CSR_BUSY_MASK)) - { - alt_busy_sleep(1); /* delay 1us */ - if(5000 <= counter) /* time_out if waiting longer than 5 msec */ - { - alt_printf("time out after 5 msec while waiting for any pending" - " transfer complete\n"); - - /* - * Now that access to the registers is complete, release the registers - * semaphore so that other threads can access the registers. - */ - ALT_SEM_POST (dev->regs_lock); - - return -ETIME; - } - counter++; - csr_status = IORD_ALTERA_MSGDMA_CSR_STATUS(dev->csr_base); - } - - - /*Errors or conditions causing the dispatcher stopping issuing read/write - commands to masters*/ - if(0 != (csr_status & error)) - { - /* - * Now that access to the registers is complete, release the registers - * semaphore so that other threads can access the registers. - */ - ALT_SEM_POST (dev->regs_lock); - - return error; - } - - /* Stop the msgdma dispatcher from issuing more descriptors to the - read or write masters */ - /* stop issuing more descriptors */ - control = IORD_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base) | - ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_MASK; - /* making sure the read-modify-write below can't be pre-empted */ - context = alt_irq_disable_all(); - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, control); - /* - * Clear any (previous) status register information - * that might occlude our error checking later. - */ - IOWR_ALTERA_MSGDMA_CSR_STATUS( - dev->csr_base, - IORD_ALTERA_MSGDMA_CSR_STATUS(dev->csr_base)); - alt_irq_enable_all(context); - - /* - * Now that access to the registers is complete, release the registers - * semaphore so that other threads can access the registers. - */ - ALT_SEM_POST (dev->regs_lock); - - return 0; - -} - -/* - * Functions for constructing standard descriptors. Unnecessary elements are - * set to 0 for completeness and will be ignored by the hardware. - * Returns: - * - status: return 0 (success) - * return -EINVAL (invalid argument, could be due to argument which - * has larger value than hardware setting value) - */ -int alt_msgdma_construct_standard_st_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *descriptor, - alt_u32 *write_address, alt_u32 length, alt_u32 control) -{ - return alt_msgdma_construct_standard_descriptor(dev, descriptor, NULL, - write_address, length, control); -} - -int alt_msgdma_construct_standard_mm_to_st_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 length, - alt_u32 control) -{ - return alt_msgdma_construct_standard_descriptor(dev, descriptor, read_address, - NULL, length, control); - -} - -int alt_msgdma_construct_standard_mm_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 *write_address, - alt_u32 length, - alt_u32 control) -{ - return alt_msgdma_construct_standard_descriptor(dev, descriptor, read_address, - write_address, length, control); -} - -/* - * Functions for constructing extended descriptors. If you disable some of the - * extended features in the hardware then you should pass in 0 for that - * particular descriptor element. These disabled elements will not be buffered - * by the dispatcher block. - * Returns: - * - status: return 0 (success) - * return -EINVAL (invalid argument, could be due to argument which - * has larger value than hardware setting value) - */ -int alt_msgdma_construct_extended_st_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *descriptor, - alt_u32 *write_address, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 write_burst_count, - alt_u16 write_stride) -{ - return alt_msgdma_construct_extended_descriptor(dev, descriptor, - NULL, write_address, length, control, sequence_number, 0, - write_burst_count, 0, write_stride); -} - -int alt_msgdma_construct_extended_mm_to_st_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 read_burst_count, - alt_u16 read_stride) -{ - return alt_msgdma_construct_extended_descriptor(dev, descriptor, read_address, - NULL, length, control, sequence_number, read_burst_count, 0, - read_stride, 0); - -} - -int alt_msgdma_construct_extended_mm_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *descriptor, - alt_u32 *read_address, - alt_u32 *write_address, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 read_burst_count, - alt_u8 write_burst_count, - alt_u16 read_stride, - alt_u16 write_stride) -{ - return alt_msgdma_construct_extended_descriptor(dev, descriptor, - read_address, write_address, length, control, sequence_number, - read_burst_count, write_burst_count, read_stride, write_stride); - -} - -/********************** MSGDMA PREFETCHER PRIVATE APIs *************************/ - -/* - * Base functions for constructing mm_to_st, st_to_mm, mm_to_mm standard - * descriptors for the prefetcher. Unnecessary elements are set to 0 for - * completeness and will be ignored by the hardware. - * The descriptor created will be suitable for park since this API will set next_ptr - * to itself as park_mode requires. Additionally OWN_BY_HW bit left as 0 (owned by sw) - * until the prefetcher is started with this descriptor in the list. - * Returns: - * - status: return 0 (success) - * return -EINVAL (invalid argument, could be due to argument which - * has larger value than hardware setting value) - */ -static int alt_msgdma_construct_prefetcher_standard_descriptor( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_standard_descriptor *descriptor, - alt_u32 read_address, - alt_u32 write_address, - alt_u32 length, - alt_u32 control) -{ - if(dev->max_byte < length || - dev->enhanced_features != 0 - ) - { - return -EINVAL; - } - descriptor->read_address = read_address; - descriptor->write_address = write_address; - descriptor->transfer_length = length; - /* have descriptor point to itself for park_mode */ - descriptor->next_desc_ptr = (alt_u32)descriptor; - - /* clear control own_by_hw bit field (SW owns this descriptor)*/ - descriptor->control = (control - & ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW_CLR_MASK) - | ALTERA_MSGDMA_DESCRIPTOR_CONTROL_GO_MASK; - - return 0; -} - -/* - * Base functions for constructing mm_to_st, st_to_mm, mm_to_mm extended - * descriptors. Unnecessary elements are set to 0 for completeness and will be - * ignored by the hardware. The descriptor created will be suitable for park - * mode since this API will set next_ptr to itself as park_mode requires. - * Additionally OWN_BY_HW bit left as 0 (owned by sw) until the prefetcher is - * started with this descriptor in the list. - * Returns: - * - status: return 0 (success) - * return -EINVAL (invalid argument, could be due to argument which - * has larger value than hardware setting value) - */ -static int alt_msgdma_construct_prefetcher_extended_descriptor( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_extended_descriptor *descriptor, - alt_u32 read_address_high, - alt_u32 read_address_low, - alt_u32 write_address_high, - alt_u32 write_address_low, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 read_burst_count, - alt_u8 write_burst_count, - alt_u16 read_stride, - alt_u16 write_stride) -{ - msgdma_addr64 node_addr; - - if(dev->max_byte < length || - dev->max_stride < read_stride || - dev->max_stride < write_stride || - dev->enhanced_features != 1 - ) - { - return -EINVAL; - } - - descriptor->read_address_high = read_address_high; - descriptor->read_address_low = read_address_low; - descriptor->write_address_high = write_address_high; - descriptor->write_address_low = write_address_low; - descriptor->transfer_length = length; - descriptor->sequence_number = sequence_number; - descriptor->read_burst_count = read_burst_count; - descriptor->write_burst_count = write_burst_count; - descriptor->read_stride = read_stride; - descriptor->write_stride = write_stride; - /* have descriptor point to itself */ - node_addr.u64 = (uintptr_t)descriptor; - descriptor->next_desc_ptr_low = node_addr.u32[0]; - descriptor->next_desc_ptr_high = node_addr.u32[1]; - - /* clear control own_by_hw bit field (SW still owns this descriptor). */ - descriptor->control = (control - & ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW_CLR_MASK) - | ALTERA_MSGDMA_DESCRIPTOR_CONTROL_GO_MASK; - - return 0 ; -} - - -/********************** MSGDMA PREFETCHER PUBLIC APIs ************************/ - -/* - * Functions for constructing standard descriptors. Unnecessary elements are - * set to 0 for completeness and will be ignored by the hardware. - * Returns: - * - status: return 0 (success) - * return -EINVAL (invalid argument, could be due to argument which - * has larger value than hardware setting value) - */ -int alt_msgdma_construct_prefetcher_standard_mm_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_standard_descriptor *descriptor, - alt_u32 read_address, - alt_u32 write_address, - alt_u32 length, - alt_u32 control) -{ - return alt_msgdma_construct_prefetcher_standard_descriptor(dev, descriptor, - read_address, write_address, length, control); -} - -int alt_msgdma_construct_prefetcher_standard_st_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_standard_descriptor *descriptor, - alt_u32 write_address, - alt_u32 length, - alt_u32 control) -{ - return alt_msgdma_construct_prefetcher_standard_descriptor(dev, descriptor, - 0, write_address, length, control); -} - -int alt_msgdma_construct_prefetcher_standard_mm_to_st_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_standard_descriptor *descriptor, - alt_u32 read_address, - alt_u32 length, - alt_u32 control) -{ - return alt_msgdma_construct_prefetcher_standard_descriptor(dev, descriptor, - read_address, 0, length, control); -} - - -/* - * Functions for constructing extended descriptors. If you disable some of the - * extended features in the hardware then you should pass in 0 for that - * particular descriptor element. These disabled elements will not be buffered - * by the dispatcher block. - * Returns: - * - status: return 0 (success) - * return -EINVAL (invalid argument, could be due to argument which - * has larger value than hardware setting value) - */ -int alt_msgdma_construct_prefetcher_extended_st_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_extended_descriptor *descriptor, - alt_u32 write_address_high, - alt_u32 write_address_low, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 write_burst_count, - alt_u16 write_stride) -{ - return alt_msgdma_construct_prefetcher_extended_descriptor(dev, descriptor, - 0, 0, write_address_high, write_address_low, length, control, - sequence_number, 0, write_burst_count, 0, write_stride); -} - -int alt_msgdma_construct_prefetcher_extended_mm_to_st_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_extended_descriptor *descriptor, - alt_u32 read_address_high, - alt_u32 read_address_low, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 read_burst_count, - alt_u16 read_stride) -{ - return alt_msgdma_construct_prefetcher_extended_descriptor(dev, descriptor, - read_address_high, read_address_low, 0, 0, length, control, - sequence_number, read_burst_count, 0, read_stride, 0); -} - -int alt_msgdma_construct_prefetcher_extended_mm_to_mm_descriptor ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_extended_descriptor *descriptor, - alt_u32 read_address_high, - alt_u32 read_address_low, - alt_u32 write_address_high, - alt_u32 write_address_low, - alt_u32 length, - alt_u32 control, - alt_u16 sequence_number, - alt_u8 read_burst_count, - alt_u8 write_burst_count, - alt_u16 read_stride, - alt_u16 write_stride) -{ - return alt_msgdma_construct_prefetcher_extended_descriptor(dev, descriptor, - read_address_high, read_address_low, write_address_high, - write_address_low, length, control, sequence_number, - read_burst_count, write_burst_count, read_stride, write_stride); - -} - -/* PREFETCHER linked list APIs */ -/* - * Function for adding standard descriptors to a standard descriptor list - * Returns: - * - status: return 0 (success) - * return -EINVAL (invalid argument, could be due to descriptor - * already being in the list, descriptor pointer being NULL, or - * descriptor.next_ptr not pointing back to itslef) - */ -int alt_msgdma_prefetcher_add_standard_desc_to_list ( - alt_msgdma_prefetcher_standard_descriptor** list, - alt_msgdma_prefetcher_standard_descriptor* descriptor) -{ - alt_msgdma_prefetcher_standard_descriptor *last_descr_ptr; - - if (descriptor == NULL) - { - return -EINVAL; /* this descriptor cannot be NULL */ - } - if (descriptor->next_desc_ptr != (alt_u32)descriptor) - { - return -EINVAL; /* descriptor.next_ptr must point to itself */ - } - if (*list == NULL) - { - *list = descriptor; /* make this root-node if list is empty */ - return 0; /* successfully added */ - } - if (*list == descriptor) - { - return -EINVAL; /* this descriptor cannot already be root-node */ - } - - /* get to last node in the list */ - last_descr_ptr = *list; /* start at list root-node */ - /* traverse list until you get the last node */ - while (last_descr_ptr->next_desc_ptr != (alt_u32)*list) - { - if (last_descr_ptr->next_desc_ptr == (alt_u32)descriptor) - { - return -EINVAL; /* descriptor cannot already be in the list */ - } - last_descr_ptr = - (alt_msgdma_prefetcher_standard_descriptor*)(last_descr_ptr->next_desc_ptr); - } - /* add this descriptor to end of list */ - last_descr_ptr->next_desc_ptr = (alt_u32)((uintptr_t)descriptor); - /* ensure new last pointer points the start of the list */ - descriptor->next_desc_ptr = (alt_u32)((uintptr_t)*list); - return 0; /* successfully added */ -} - -int alt_msgdma_prefetcher_add_extended_desc_to_list ( - alt_msgdma_prefetcher_extended_descriptor** list, - alt_msgdma_prefetcher_extended_descriptor* descriptor) -{ - alt_msgdma_prefetcher_extended_descriptor *last_descr_ptr; - msgdma_addr64 root_node_addr, next_node_addr; - - if (descriptor == NULL) - { - return -EINVAL; /* this descriptor cannot be NULL */ - } - - next_node_addr.u64 = (uintptr_t)descriptor; - if( (descriptor->next_desc_ptr_low != next_node_addr.u32[0]) && - (descriptor->next_desc_ptr_high != next_node_addr.u32[1])) - { - return -EINVAL; /* descriptor.next_ptr must point to itself */ - } - - if (*list == NULL) - { - *list = descriptor; /* make this the root-node if list is empty */ - return 0; - } - if (*list == descriptor) - { - return -EINVAL; /* this descriptor cannot already be root-node */ - } - - /* get to last node in the list */ - last_descr_ptr = *list; /* start at list root-node */ - /* the last nodes next ptr should point to the root node*/ - root_node_addr.u64 = (uintptr_t)*list; - - /* traverse list until you get the last node */ - while ((last_descr_ptr->next_desc_ptr_low != root_node_addr.u32[0]) - && (last_descr_ptr->next_desc_ptr_high != root_node_addr.u32[1])) - { - /* first check if descriptor already in the list */ - next_node_addr.u64 = (uintptr_t)descriptor; - if ((last_descr_ptr->next_desc_ptr_low == next_node_addr.u32[0]) - && (last_descr_ptr->next_desc_ptr_high == next_node_addr.u32[1])) - { - return -EINVAL; /* descriptor cannot already be in the list */ - } - /* go to next node in list, using 64 bit address */ - next_node_addr.u32[0] = last_descr_ptr->next_desc_ptr_low; - next_node_addr.u32[1] = last_descr_ptr->next_desc_ptr_high; - last_descr_ptr = - (alt_msgdma_prefetcher_extended_descriptor*)((uintptr_t)next_node_addr.u64); - } - /* add this descriptor to end of list */ - next_node_addr.u64 = (uintptr_t)descriptor; - last_descr_ptr->next_desc_ptr_low = next_node_addr.u32[0]; - last_descr_ptr->next_desc_ptr_high = next_node_addr.u32[1]; - /* ensure new last pointer points the beginning of the list */ - descriptor->next_desc_ptr_low = root_node_addr.u32[0]; - descriptor->next_desc_ptr_high = root_node_addr.u32[1]; - return 0; -} - -/* - * Functions to set all the own-by-hw bits, need to call right before starting - * prefetcher since if used the create descriptor APIs the set_by_hw bits are - * still set to SW owned. - */ -int alt_msgdma_prefetcher_set_std_list_own_by_hw_bits ( - alt_msgdma_prefetcher_standard_descriptor *list) -{ - alt_u32 descriptor_control_field = 0; - alt_msgdma_prefetcher_standard_descriptor *last_descr_ptr; - if (list == NULL) - { - return -EINVAL; /* this list cannot be empty */ - } - - /* update all nodes in the list */ - last_descr_ptr = list; /* start at list root-node */ - /* traverse list to update all of the nodes */ - while (last_descr_ptr->next_desc_ptr != (alt_u32)list) - { - /* get current value */ - descriptor_control_field = last_descr_ptr->control; - /* update own_by_hw bit only */ - last_descr_ptr->control = descriptor_control_field - | ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW_SET_MASK; - /* go to next node in list */ - last_descr_ptr = - (alt_msgdma_prefetcher_standard_descriptor*)(last_descr_ptr->next_desc_ptr); - } - /* update the last node in the list, currently last_descr_ptr after while loop */ - descriptor_control_field = last_descr_ptr->control; /* get current value */ - /* update own_by_hw bit only */ - last_descr_ptr->control = descriptor_control_field - | ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW_SET_MASK; - - return 0; -} - -/* - * Functions to set all the own-by-hw bits, need to call right before starting - * prefetcher since if used the create descriptor APIs the set_by_hw bits are - * still set to SW owned. - */ -int alt_msgdma_prefetcher_set_extd_list_own_by_hw_bits ( - alt_msgdma_prefetcher_extended_descriptor *list) -{ - alt_u32 descriptor_control_field = 0; - msgdma_addr64 root_node_addr, next_node_addr; - alt_msgdma_prefetcher_extended_descriptor *last_descr_ptr; - - if (list == NULL) - { - return -EINVAL; /* this list cannot be empty */ - } - - /* update all nodes in the list */ - last_descr_ptr = list; /* start at list root-node */ - /* the last nodes next ptr should point to the root node*/ - root_node_addr.u64 = (uintptr_t)list; - - /* traverse list until you get the last node */ - while ((last_descr_ptr->next_desc_ptr_low != root_node_addr.u32[0]) - && (last_descr_ptr->next_desc_ptr_high != root_node_addr.u32[1])) - { - /* start with current value */ - descriptor_control_field = last_descr_ptr->control; - /* update own_by_hw bit only */ - last_descr_ptr->control = descriptor_control_field - | ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW_SET_MASK; - /* go to next node in list, using 64 bit address */ - next_node_addr.u32[0] = last_descr_ptr->next_desc_ptr_low; - next_node_addr.u32[1] = last_descr_ptr->next_desc_ptr_high; - last_descr_ptr = - (alt_msgdma_prefetcher_extended_descriptor*)((uintptr_t)next_node_addr.u64); - } - /* update the last node in the list, currently last_descr_ptr after while loop */ - descriptor_control_field = last_descr_ptr->control; /* start with current value */ - /* update own_by_hw bit only */ - last_descr_ptr->control = descriptor_control_field - | ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW_SET_MASK; - return 0; -} - - -/* - * Functions to start the prefetcher. Will return error if prefetcher already - * started. - * - * Arguments:# This driver supports HAL types - * - *dev: Pointer to msgdma device (instance) structure. - * - *standard_desc: Pointer to single standard descriptor OR *extended_desc: - * Pointer to single extended descriptor. - * - park_mode_en: setting for prefetcher park mode - * - poll_en: setting for poll_en (IF poll frequency still 0 this API will - * also set that to a default non-zero value) - * - *note: Must call API specific to descriptor type. Either - * alt_msgdma_start_prefetcher_with_std_desc_list OR - * alt_msgdma_start_prefetcher_with_extd_desc_list - * where the list paratmeter is the root-node of your linked list. Then those - * APIs will call the base function accordingly. - * - * If a callback routine has been previously registered with this - * particular msgdma controller, transfer will be set up to enable interrupt - * generation. It is the responsibility of the application developer to check - * source interruption, status completion and creating suitable interrupt - * handling. - * Note: "stop on error" of CSR control register is always masking within this - * function. The CSR control can be set by user through calling - * "alt_register_callback" by passing user used defined control setting. - * - * Returns: - * 0 -> success - * -EBUSY -> prefetcher busy processing list already, it is up to user to stop - * prefetcher/dispatcher correctly before calling this function. - * if already busy will always return error. - */ - -/* - * Base function to start prefetcher. - */ -int alt_msgdma_start_prefetcher_with_list_addr ( - alt_msgdma_dev *dev, - alt_u64 list_addr, - alt_u8 park_mode_en, - alt_u8 poll_en) -{ - alt_u32 prefetcher_ctl = 0; - alt_u32 dispatcher_ctl = 0; - alt_irq_context context = 0; - - /* use helper struct to get easy access to hi/low address */ - msgdma_addr64 root_node_addr; - root_node_addr.u64 = list_addr; - - /* - * When running in a multi threaded environment, obtain the "regs_lock" - * semaphore. This ensures that accessing registers is thread-safe. - */ - ALT_SEM_PEND (dev->regs_lock, 0); - - /* case where prefetcher already started, return busy error */ - prefetcher_ctl = IORD_ALT_MSGDMA_PREFETCHER_CONTROL(dev->prefetcher_base); - if(ALT_MSGDMA_PREFETCHER_CTRL_RUN_GET(prefetcher_ctl)){ - /* release the registers semaphore */ - ALT_SEM_POST (dev->regs_lock); - return -EBUSY; - } - - /* Stop the msgdma dispatcher from issuing more descriptors to the - read or write masters */ - /* stop issuing more descriptors */ - dispatcher_ctl = ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_MASK; - - /* making sure the read-modify-write below can't be pre-empted */ - context = alt_irq_disable_all(); - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, dispatcher_ctl); - /* - * Clear any (previous) status register information - * that might occlude our error checking later. - */ - IOWR_ALTERA_MSGDMA_CSR_STATUS( dev->csr_base, - IORD_ALTERA_MSGDMA_CSR_STATUS(dev->csr_base)); - - alt_irq_enable_all(context); - - /* - * If a callback routine has been previously registered which will be - * called from the msgdma ISR. Set up dispatcher to: - * - Run - * - Stop on an error with any particular descriptor - */ - if(dev->callback) - { - dispatcher_ctl |= (dev->control | ALTERA_MSGDMA_CSR_STOP_ON_ERROR_MASK - | ALTERA_MSGDMA_CSR_GLOBAL_INTERRUPT_MASK ); - dispatcher_ctl &= (~ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_MASK); - - prefetcher_ctl |= ALT_MSGDMA_PREFETCHER_CTRL_GLOBAL_INTR_EN_SET_MASK; - /* making sure the read-modify-write below can't be pre-empted */ - context = alt_irq_disable_all(); - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, dispatcher_ctl); - IOWR_ALT_MSGDMA_PREFETCHER_CONTROL(dev->prefetcher_base, prefetcher_ctl); - alt_irq_enable_all(context); - } - /* - * No callback has been registered. Set up dispatcher to: - * - Run - * - Stop on an error with any particular descriptor - * - Disable interrupt generation - */ - else - { - dispatcher_ctl |= (dev->control | ALTERA_MSGDMA_CSR_STOP_ON_ERROR_MASK); - dispatcher_ctl &= (~ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_MASK) - & (~ALTERA_MSGDMA_CSR_GLOBAL_INTERRUPT_MASK); - prefetcher_ctl &= ALT_MSGDMA_PREFETCHER_CTRL_GLOBAL_INTR_EN_CLR_MASK; - /* making sure the read-modify-write below can't be pre-empted */ - context = alt_irq_disable_all(); - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, dispatcher_ctl); - IOWR_ALT_MSGDMA_PREFETCHER_CONTROL(dev->prefetcher_base, prefetcher_ctl); - alt_irq_enable_all(context); - } - - /* set next descriptor registers to point to the list root-node */ - IOWR_ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW(dev->prefetcher_base, - root_node_addr.u32[0]); - IOWR_ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH(dev->prefetcher_base, - root_node_addr.u32[1]); - - /* set park-mode */ - if (park_mode_en){ - prefetcher_ctl |= ALT_MSGDMA_PREFETCHER_CTRL_PARK_MODE_SET_MASK; - } - else { - prefetcher_ctl &= ALT_MSGDMA_PREFETCHER_CTRL_PARK_MODE_CLR_MASK; - } - - /* set poll-en */ - if (poll_en){ - prefetcher_ctl |= ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN_MASK; - if(IORD_ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLLING_FREQ( - dev->prefetcher_base) == 0){ - /* set poll frequency to some non-zero default value */ - IOWR_ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLLING_FREQ( - dev->prefetcher_base, 0xFF); - } - } - else { - prefetcher_ctl &= ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN_CLR_MASK; - } - - /* set the prefetcher run bit */ - prefetcher_ctl |= ALT_MSGDMA_PREFETCHER_CTRL_RUN_SET_MASK; - /* start the dma since run bit is set */ - IOWR_ALT_MSGDMA_PREFETCHER_CONTROL(dev->prefetcher_base, prefetcher_ctl); - - /* - * Now that access to the registers is complete, release the registers - * semaphore so that other threads can access the registers. - */ - ALT_SEM_POST (dev->regs_lock); - - return 0; -} - -/* - * Public functions to start prefetcher. - */ -int alt_msgdma_start_prefetcher_with_std_desc_list ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_standard_descriptor *list, - alt_u8 park_mode_en, - alt_u8 poll_en) -{ - if (alt_msgdma_prefetcher_set_std_list_own_by_hw_bits(list) != 0){ - return -EINVAL; - } - - return alt_msgdma_start_prefetcher_with_list_addr (dev, (uintptr_t)list, - park_mode_en, poll_en); -} - -int alt_msgdma_start_prefetcher_with_extd_desc_list ( - alt_msgdma_dev *dev, - alt_msgdma_prefetcher_extended_descriptor *list, - alt_u8 park_mode_en, - alt_u8 poll_en) -{ - if (alt_msgdma_prefetcher_set_extd_list_own_by_hw_bits(list) != 0){ - return -EINVAL; - } - return alt_msgdma_start_prefetcher_with_list_addr (dev, (uintptr_t)list, - park_mode_en, poll_en); -} - - -/* - * alt_msgdma_open - Retrieve a pointer to the msgdma - * - * Search the list of registered msgdma for one with the supplied name. - * - * The return value will be NULL on failure, and non-NULL otherwise. - * - * Arguments: - * - *name: Character pointer to name of msgdma peripheral as registered - * with the HAL. For example, an msgdma controller named "msgdma_0" - * in Qsys would be opened by asking for "/dev/msgdma_0_csr". - * - * Returns: - * - Pointer to msgdma device instance structure, or null if the device - * could not be opened. - */ -alt_msgdma_dev* alt_msgdma_open (const char* name) -{ - alt_msgdma_dev* dev = NULL; - - dev = (alt_msgdma_dev*) alt_find_dev (name, &alt_msgdma_list); - - if (NULL == dev) - { - ALT_ERRNO = ENODEV; - } - - return dev; -} - - -/* - * alt_msgdma_init() - * - * Initializes the Modular Scatter-Gather DMA controller. This routine is called - * from the ALTERA_MSGDMA_INIT macro and is called automatically - * by alt_sys_init.c - * - * This routine disables interrupts, descriptor processing, - * registers a specific instance of the device with the HAL, - * and installs an interrupt handler for the device. - */ -void alt_msgdma_init (alt_msgdma_dev *dev, alt_u32 ic_id, alt_u32 irq) -{ - extern alt_llist alt_msgdma_list; - alt_u32 temporary_control; - int error; - - if (dev->prefetcher_enable) - { - /* start prefetcher reset sequence */ - IOWR_ALT_MSGDMA_PREFETCHER_CONTROL(dev->prefetcher_base, - ALT_MSGDMA_PREFETCHER_CTRL_RESET_SET_MASK); - /* wait until hw clears the bit */ - while(ALT_MSGDMA_PREFETCHER_CTRL_RESET_GET( - IORD_ALT_MSGDMA_PREFETCHER_CONTROL(dev->prefetcher_base))); - /* - * This reset is intended to be used along with reset dispatcher in - * dispatcher core. Once the reset sequence in prefetcher core has - * completed, software is expected to reset the dispatcher core, - * and polls for dispatcher’s reset sequence to be completed. - */ - } - - /* Reset the registers and FIFOs of the dispatcher and master modules */ - /* set the reset bit, no need to read the control register first since - this write is going to clear it out */ - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, ALTERA_MSGDMA_CSR_RESET_MASK); - while(0 != (IORD_ALTERA_MSGDMA_CSR_STATUS(dev->csr_base) - & ALTERA_MSGDMA_CSR_RESET_STATE_MASK)); - /* - * Disable interrupts, halt descriptor processing, - * and clear status register content - */ - - /* disable global interrupt */ - temporary_control = IORD_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base) - & (~ALTERA_MSGDMA_CSR_GLOBAL_INTERRUPT_MASK); - /* stopping descriptor */ - temporary_control |= ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_MASK; - IOWR_ALTERA_MSGDMA_CSR_CONTROL(dev->csr_base, temporary_control); - - /* clear the CSR status register */ - IOWR_ALTERA_MSGDMA_CSR_STATUS(dev->csr_base, - IORD_ALTERA_MSGDMA_CSR_STATUS(dev->csr_base)); - - if (dev->prefetcher_enable) - { - /* clear all status bits that are set, since theyre W1C */ - IOWR_ALT_MSGDMA_PREFETCHER_STATUS(dev->prefetcher_base, - IORD_ALT_MSGDMA_PREFETCHER_STATUS(dev->prefetcher_base)); - } - - /* Register this instance of the msgdma controller with HAL */ - alt_dev_llist_insert((alt_dev_llist*) dev, &alt_msgdma_list); - - /* - * Creating semaphores used to protect access to the registers - * when running in a multi-threaded environment. - */ - error = ALT_SEM_CREATE (&dev->regs_lock, 1); - - if (!error) - { - /* Install IRQ handler */ - alt_ic_isr_register(ic_id, irq, alt_msgdma_irq, dev, 0x0); - } - else - { - alt_printf("failed to create semaphores\n"); - } - - return; - -} - - -/* - * alt_msgdma_register_callback - * - * Associate a user-specific routine with the msgdma interrupt handler. - * If a callback is registered, all non-blocking msgdma transfers will - * enable interrupts that will cause the callback to be executed. - * The callback runs as part of the interrupt service routine, and - * great care must be taken to follow the guidelines for acceptable - * interrupt service routine behaviour as described in the Nios II - * Software Developer's Handbook.However, user can change some of the CSR - * control setting in blocking transfer by calling this function. - * - * Note: To disable callbacks after registering one, this routine - * may be called passing 0x0 to the callback argument. - * - * Arguments: - * - *dev: Pointer to msgdma device (instance) structure. - * - callback: Pointer to callback routine to execute at interrupt level - * - control: For masking the source interruption and setting configuration in - * control register - */ -void alt_msgdma_register_callback( - alt_msgdma_dev *dev, - alt_msgdma_callback callback, - alt_u32 control, - void *context) -{ - dev->callback = callback; - dev->callback_context = context; - dev->control = control; - - return ; -} - -/* - * alt_msgdma_standard_descriptor_async_transfer - * - * Set up and commence a non-blocking transfer of one descriptors at a time. - * - * If the FIFO buffer for one of read/write is full at the time of this call, - * the routine will immediately return -ENOSPC, the application can then decide - * how to proceed without being blocked. - * - * Arguments: - * - *dev: Pointer to msgdma device (instance) struct. - * - *desc: Pointer to single (ready to run) descriptor. - * - * Returns: - * 0 -> success - * -ENOSPC -> FIFO descriptor buffer is full - * -EPERM -> operation not permitted due to descriptor type conflict - * -ETIME -> Time out and skipping the looping after 5 msec. - */ -int alt_msgdma_standard_descriptor_async_transfer( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *desc) -{ - /* - * Error detection/handling should be performed at the application - * or callback level as appropriate. - */ - return alt_msgdma_descriptor_async_transfer(dev, desc, NULL); - -} - - -/* - * alt_msgdma_extended_descriptor_async_transfer - * - * Set up and commence a non-blocking transfer of one descriptors at a time. - * - * If the FIFO buffer for one of read/write is full at the time of this call, - * the routine will immediately return -ENOSPC, the application can then - * decide how to proceed without being blocked. - * - * Arguments: - * - *dev: Pointer to msgdma device (instance) struct. - * - *desc: Pointer to single (ready to run) descriptor. - * - * Returns: - * 0 -> success - * -ENOSPC -> FIFO descriptor buffer is full - * -EPERM -> operation not permitted due to descriptor type conflict - * -ETIME -> Time out and skipping the looping after 5 msec. - */ -int alt_msgdma_extended_descriptor_async_transfer( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *desc) -{ - /* - * Error detection/handling should be performed at the application - * or callback level as appropriate. - */ - return alt_msgdma_descriptor_async_transfer(dev, NULL, desc); -} - - -/* - * alt_msgdma_standard_descriptor_sync_transfer - * - * This function will start commencing a blocking transfer of one standard - * descriptor at a time. If the FIFO buffer for one of read/write is full at the - * time of this call, the routine will wait until free FIFO buffer available for - * continue processing. - * - * The function will return "-1" if errors or conditions causing the dispatcher - * stop issuing the commands to both read and write masters before both read and - * write command buffers are empty. - * - * Additional error information is available in the status bits of - * each descriptor that the msgdma processed; it is the responsibility - * of the user's application to search through the descriptor - * to gather specific error information. - * - * Arguments: - * - *dev: Pointer to msgdma device (instance) structure. - * - *desc: Pointer to single (ready to run) descriptor. - * - * Returns: - * - status: return 0 (success) - * return error (errors or conditions causing msgdma stop issuing - * commands to masters) - * Suggest suggest checking the bit set in the error with CSR status - * register. - * return -EPERM (operation not permitted due to descriptor type - * conflict) - * return -ETIME (Time out and skipping the looping after 5 msec) - */ -int alt_msgdma_standard_descriptor_sync_transfer( - alt_msgdma_dev *dev, - alt_msgdma_standard_descriptor *desc) -{ - return alt_msgdma_descriptor_sync_transfer(dev, desc, NULL); -} - -/* - * alt_msgdma_extended_descriptor_sync_transfer - * - * This function will start commencing a blocking transfer of one extended - * descriptor at a time. If the FIFO buffer for one of read/write is full at the - * time of this call, the routine will wait until free FIFO buffer available for - * continue processing. - * - * The function will return "-1" if errors or conditions causing the dispatcher - * stop issuing the commands to both read and write masters before both read and - * write command buffers are empty. - * - * Additional error information is available in the status bits of - * each descriptor that the msgdma processed; it is the responsibility - * of the user's application to search through the descriptor - * to gather specific error information. - * - * - * Arguments: - * - *dev: Pointer to msgdma device (instance) structure. - * - *desc: Pointer to single (ready to run) descriptor. - * - * Returns: - * - status: return 0 (success) - * return error (errors or conditions causing msgdma stop issuing - * commands to masters) - * Suggest suggest checking the bit set in the error with CSR status - * register. - * return -EPERM (operation not permitted due to descriptor type - * conflict) - * return -ETIME (Time out and skipping the looping after 5 msec) - */ -int alt_msgdma_extended_descriptor_sync_transfer( - alt_msgdma_dev *dev, - alt_msgdma_extended_descriptor *desc) -{ - return alt_msgdma_descriptor_sync_transfer(dev, NULL, desc); -} diff --git a/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_csr_regs.h b/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_csr_regs.h deleted file mode 100644 index 3fde78ba1f..0000000000 --- a/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_csr_regs.h +++ /dev/null @@ -1,171 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2014 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -******************************************************************************/ - -#ifndef ALTERA_MSGDMA_CSR_REGS_H_ -#define ALTERA_MSGDMA_CSR_REGS_H_ - -#include "io.h" -/* - Enhanced features off: - - Bytes Access Type Description - ----- ----------- ----------- - 0-3 R/Clr Status(1) - 4-7 R/W Control(2) - 8-12 R Descriptor Fill Level(write fill level[15:0], read - fill level[15:0]) - 13-15 R Response Fill Level[15:0] - 16-31 N/A - - - Enhanced features on: - - Bytes Access Type Description - ----- ----------- ----------- - 0-3 R/Clr Status(1) - 4-7 R/W Control(2) - 8-12 R Descriptor Fill Level (write fill level[15:0], read - fill level[15:0]) - 13-15 R Response Fill Level[15:0] - 16-20 R Sequence Number (write sequence number[15:0], read - sequence number[15:0]) - 21-31 N/A - - (1) Writing a '1' to the interrupt bit of the status register clears the - interrupt bit (when applicable), all other bits are unaffected by writes. - (2) Writing to the software reset bit will clear the entire register - (as well as all the registers for the entire msgdma). - - Status Register: - - Bits Description - ---- ----------- - 0 Busy - 1 Descriptor Buffer Empty - 2 Descriptor Buffer Full - 3 Response Buffer Empty - 4 Response Buffer Full - 5 Stop State - 6 Reset State - 7 Stopped on Error - 8 Stopped on Early Termination - 9 IRQ - 10-31 - - Control Register: - - Bits Description - ---- ----------- - 0 Stop (will also be set if a stop on error/early termination - condition occurs) - 1 Software Reset - 2 Stop on Error - 3 Stop on Early Termination - 4 Global Interrupt Enable Mask - 5 Stop dispatcher (stops the dispatcher from issuing more read/write - commands) - 6-31 -*/ - - - -#define ALTERA_MSGDMA_CSR_STATUS_REG 0x0 -#define ALTERA_MSGDMA_CSR_CONTROL_REG 0x4 -#define ALTERA_MSGDMA_CSR_DESCRIPTOR_FILL_LEVEL_REG 0x8 -#define ALTERA_MSGDMA_CSR_RESPONSE_FILL_LEVEL_REG 0xC -/* this register only exists when the enhanced features are enabled */ -#define ALTERA_MSGDMA_CSR_SEQUENCE_NUMBER_REG 0x10 - - -/* masks for the status register bits */ -#define ALTERA_MSGDMA_CSR_BUSY_MASK 1 -#define ALTERA_MSGDMA_CSR_BUSY_OFFSET 0 -#define ALTERA_MSGDMA_CSR_DESCRIPTOR_BUFFER_EMPTY_MASK (1 << 1) -#define ALTERA_MSGDMA_CSR_DESCRIPTOR_BUFFER_EMPTY_OFFSET 1 -#define ALTERA_MSGDMA_CSR_DESCRIPTOR_BUFFER_FULL_MASK (1 << 2) -#define ALTERA_MSGDMA_CSR_DESCRIPTOR_BUFFER_FULL_OFFSET 2 -#define ALTERA_MSGDMA_CSR_RESPONSE_BUFFER_EMPTY_MASK (1 << 3) -#define ALTERA_MSGDMA_CSR_RESPONSE_BUFFER_EMPTY_OFFSET 3 -#define ALTERA_MSGDMA_CSR_RESPONSE_BUFFER_FULL_MASK (1 << 4) -#define ALTERA_MSGDMA_CSR_RESPONSE_BUFFER_FULL_OFFSET 4 -#define ALTERA_MSGDMA_CSR_STOP_STATE_MASK (1 << 5) -#define ALTERA_MSGDMA_CSR_STOP_STATE_OFFSET 5 -#define ALTERA_MSGDMA_CSR_RESET_STATE_MASK (1 << 6) -#define ALTERA_MSGDMA_CSR_RESET_STATE_OFFSET 6 -#define ALTERA_MSGDMA_CSR_STOPPED_ON_ERROR_MASK (1 << 7) -#define ALTERA_MSGDMA_CSR_STOPPED_ON_ERROR_OFFSET 7 -#define ALTERA_MSGDMA_CSR_STOPPED_ON_EARLY_TERMINATION_MASK (1 << 8) -#define ALTERA_MSGDMA_CSR_STOPPED_ON_EARLY_TERMINATION_OFFSET 8 -#define ALTERA_MSGDMA_CSR_IRQ_SET_MASK (1 << 9) -#define ALTERA_MSGDMA_CSR_IRQ_SET_OFFSET 9 - -/* masks for the control register bits */ -#define ALTERA_MSGDMA_CSR_STOP_MASK 1 -#define ALTERA_MSGDMA_CSR_STOP_OFFSET 0 -#define ALTERA_MSGDMA_CSR_RESET_MASK (1 << 1) -#define ALTERA_MSGDMA_CSR_RESET_OFFSET 1 -#define ALTERA_MSGDMA_CSR_STOP_ON_ERROR_MASK (1 << 2) -#define ALTERA_MSGDMA_CSR_STOP_ON_ERROR_OFFSET 2 -#define ALTERA_MSGDMA_CSR_STOP_ON_EARLY_TERMINATION_MASK (1 << 3) -#define ALTERA_MSGDMA_CSR_STOP_ON_EARLY_TERMINATION_OFFSET 3 -#define ALTERA_MSGDMA_CSR_GLOBAL_INTERRUPT_MASK (1 << 4) -#define ALTERA_MSGDMA_CSR_GLOBAL_INTERRUPT_OFFSET 4 -#define ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_MASK (1 << 5) -#define ALTERA_MSGDMA_CSR_STOP_DESCRIPTORS_OFFSET 5 - -/* masks for the FIFO fill levels and sequence number */ -#define ALTERA_MSGDMA_CSR_READ_FILL_LEVEL_MASK 0xFFFF -#define ALTERA_MSGDMA_CSR_READ_FILL_LEVEL_OFFSET 0 -#define ALTERA_MSGDMA_CSR_WRITE_FILL_LEVEL_MASK 0xFFFF0000 -#define ALTERA_MSGDMA_CSR_WRITE_FILL_LEVEL_OFFSET 16 -#define ALTERA_MSGDMA_CSR_RESPONSE_FILL_LEVEL_MASK 0xFFFF -#define ALTERA_MSGDMA_CSR_RESPONSE_FILL_LEVEL_OFFSET 0 -#define ALTERA_MSGDMA_CSR_READ_SEQUENCE_NUMBER_MASK 0xFFFF -#define ALTERA_MSGDMA_CSR_READ_SEQUENCE_NUMBER_OFFSET 0 -#define ALTERA_MSGDMA_CSR_WRITE_SEQUENCE_NUMBER_MASK 0xFFFF0000 -#define ALTERA_MSGDMA_CSR_WRITE_SEQUENCE_NUMBER_OFFSET 16 - - -/* read/write macros for each 32 bit register of the CSR port */ -#define IOWR_ALTERA_MSGDMA_CSR_STATUS(base, data) \ - IOWR_32DIRECT(base, ALTERA_MSGDMA_CSR_STATUS_REG, data) -#define IOWR_ALTERA_MSGDMA_CSR_CONTROL(base, data) \ - IOWR_32DIRECT(base, ALTERA_MSGDMA_CSR_CONTROL_REG, data) -#define IORD_ALTERA_MSGDMA_CSR_STATUS(base) \ - IORD_32DIRECT(base, ALTERA_MSGDMA_CSR_STATUS_REG) -#define IORD_ALTERA_MSGDMA_CSR_CONTROL(base) \ - IORD_32DIRECT(base, ALTERA_MSGDMA_CSR_CONTROL_REG) -#define IORD_ALTERA_MSGDMA_CSR_DESCRIPTOR_FILL_LEVEL(base) \ - IORD_32DIRECT(base, ALTERA_MSGDMA_CSR_DESCRIPTOR_FILL_LEVEL_REG) -#define IORD_ALTERA_MSGDMA_CSR_RESPONSE_FILL_LEVEL(base) \ - IORD_32DIRECT(base, ALTERA_MSGDMA_CSR_RESPONSE_FILL_LEVEL_REG) -#define IORD_ALTERA_MSGDMA_CSR_SEQUENCE_NUMBER(base) \ - IORD_32DIRECT(base, ALTERA_MSGDMA_CSR_SEQUENCE_NUMBER_REG) - - - -#endif /*ALTERA_MSGDMA_ALTERA_MSGDMA_CSR_REGS_H_*/ diff --git a/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_descriptor_regs.h b/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_descriptor_regs.h deleted file mode 100644 index 40dc1bd4c8..0000000000 --- a/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_descriptor_regs.h +++ /dev/null @@ -1,159 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2014 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -******************************************************************************/ - -#ifndef ALTERA_MSGDMA_DESCRIPTOR_REGS_H_ -#define ALTERA_MSGDMA_DESCRIPTOR_REGS_H_ - -#include "io.h" - -/* - Descriptor formats: - - Standard Format: - - Offset | 3 2 1 0 - ------------------------------------------------------------------------------ - 0x0 | Read Address[31..0] - 0x4 | Write Address[31..0] - 0x8 | Length[31..0] - 0xC | Control[31..0] - - Extended Format: - -Offset| 3 2 1 0 - ------------------------------------------------------------------------------ - 0x0 | Read Address[31..0] - 0x4 | Write Address[31..0] - 0x8 | Length[31..0] - 0xC |Write Burst Count[7..0] | Read Burst Count[7..0] | Sequence Number[15..0] - 0x10 | Write Stride[15..0] | Read Stride[15..0] - 0x14 | Read Address[63..32] - 0x18 | Write Address[63..32] - 0x1C | Control[31..0] - - Note: The control register moves from offset 0xC to 0x1C depending on the - format used - -*/ - - - - -#define ALTERA_MSGDMA_DESCRIPTOR_READ_ADDRESS_REG 0x0 -#define ALTERA_MSGDMA_DESCRIPTOR_WRITE_ADDRESS_REG 0x4 -#define ALTERA_MSGDMA_DESCRIPTOR_LENGTH_REG 0x8 -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_STANDARD_REG 0xC -#define ALTERA_MSGDMA_DESCRIPTOR_SEQUENCE_NUMBER_REG 0xC -#define ALTERA_MSGDMA_DESCRIPTOR_READ_BURST_REG 0xE -#define ALTERA_MSGDMA_DESCRIPTOR_WRITE_BURST_REG 0xF -#define ALTERA_MSGDMA_DESCRIPTOR_READ_STRIDE_REG 0x10 -#define ALTERA_MSGDMA_DESCRIPTOR_WRITE_STRIDE_REG 0x12 -#define ALTERA_MSGDMA_DESCRIPTOR_READ_ADDRESS_HIGH_REG 0x14 -#define ALTERA_MSGDMA_DESCRIPTOR_WRITE_ADDRESS_HIGH_REG 0x18 -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_ENHANCED_REG 0x1C - - -/* masks and offsets for the sequence number and programmable burst counts */ -#define ALTERA_MSGDMA_DESCRIPTOR_SEQUENCE_NUMBER_MASK 0xFFFF -#define ALTERA_MSGDMA_DESCRIPTOR_SEQUENCE_NUMBER_OFFSET 0 -#define ALTERA_MSGDMA_DESCRIPTOR_READ_BURST_COUNT_MASK 0x00FF0000 -#define ALTERA_MSGDMA_DESCRIPTOR_READ_BURST_COUNT_OFFSET 16 -#define ALTERA_MSGDMA_DESCRIPTOR_WRITE_BURST_COUNT_MASK 0xFF000000 -#define ALTERA_MSGDMA_DESCRIPTOR_WRITE_BURST_COUNT_OFFSET 24 - - -/* masks and offsets for the read and write strides */ -#define ALTERA_MSGDMA_DESCRIPTOR_READ_STRIDE_MASK 0xFFFF -#define ALTERA_MSGDMA_DESCRIPTOR_READ_STRIDE_OFFSET 0 -#define ALTERA_MSGDMA_DESCRIPTOR_WRITE_STRIDE_MASK 0xFFFF0000 -#define ALTERA_MSGDMA_DESCRIPTOR_WRITE_STRIDE_OFFSET 16 - - -/* masks and offsets for the bits in the descriptor control field */ -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_TRANSMIT_CHANNEL_MASK 0xFF -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_TRANSMIT_CHANNEL_OFFSET 0 -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_GENERATE_SOP_MASK (1 << 8) -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_GENERATE_SOP_OFFSET 8 -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_GENERATE_EOP_MASK (1 << 9) -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_GENERATE_EOP_OFFSET 9 -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_PARK_READS_MASK (1 << 10) -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_PARK_READS_OFFSET 10 -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_PARK_WRITES_MASK (1 << 11) -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_PARK_WRITES_OFFSET 11 -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_END_ON_EOP_MASK (1 << 12) -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_END_ON_EOP_OFFSET 12 -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_TRANSFER_COMPLETE_IRQ_MASK (1 << 14) -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_TRANSFER_COMPLETE_IRQ_OFFSET 14 -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_EARLY_TERMINATION_IRQ_MASK (1 << 15) -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_EARLY_TERMINATION_IRQ_OFFSET 15 -/* the read master will use this as the transmit error, the dispatcher will use -this to generate an interrupt if any of the error bits are asserted by the -write master */ -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_ERROR_IRQ_MASK (0xFF << 16) -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_ERROR_IRQ_OFFSET 16 -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_EARLY_DONE_ENABLE_MASK (1 << 24) -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_EARLY_DONE_ENABLE_OFFSET 24 -/* at a minimum you always have to write '1' to this bit as it commits the -descriptor to the dispatcher */ -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_GO_MASK (1 << 31) -#define ALTERA_MSGDMA_DESCRIPTOR_CONTROL_GO_OFFSET 31 - -/* Each register is byte lane accessible so the some of the values that are - * less than 32 bits wide are written to according to the field width. - */ -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_READ_ADDRESS(base, data) \ - IOWR_32DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_READ_ADDRESS_REG, data) -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_WRITE_ADDRESS(base, data) \ - IOWR_32DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_WRITE_ADDRESS_REG, data) -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_LENGTH(base, data) \ - IOWR_32DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_LENGTH_REG, data) -/* this pushes the descriptor into the read/write FIFOs when standard descriptors -are used */ -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_CONTROL_STANDARD(base, data) \ - IOWR_32DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_CONTROL_STANDARD_REG, data) -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_SEQUENCE_NUMBER(base, data) \ - IOWR_16DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_SEQUENCE_NUMBER_REG, data) -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_READ_BURST(base, data) \ - IOWR_8DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_READ_BURST_REG, data) -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_WRITE_BURST(base, data) \ - IOWR_8DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_WRITE_BURST_REG, data) -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_READ_STRIDE(base, data) \ - IOWR_16DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_READ_STRIDE_REG, data) -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_WRITE_STRIDE(base, data) \ - IOWR_16DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_WRITE_STRIDE_REG, data) -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_READ_ADDRESS_HIGH(base, data) \ - IOWR_32DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_READ_ADDRESS_HIGH_REG, data) -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_WRITE_ADDRESS_HIGH(base, data) \ - IOWR_32DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_WRITE_ADDRESS_HIGH_REG, data) -/* this pushes the descriptor into the read/write FIFOs when the extended -descriptors are used */ -#define IOWR_ALTERA_MSGDMA_DESCRIPTOR_CONTROL_ENHANCED(base, data) \ - IOWR_32DIRECT(base, ALTERA_MSGDMA_DESCRIPTOR_CONTROL_ENHANCED_REG, data) - - - -#endif /*ALTERA_MSGDMA_ALTERA_MSGDMA_DESCRIPTOR_REGS_H_*/ diff --git a/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_prefetcher_regs.h b/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_prefetcher_regs.h deleted file mode 100644 index 42cb1016b0..0000000000 --- a/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_prefetcher_regs.h +++ /dev/null @@ -1,288 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2015 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -******************************************************************************/ - -#ifndef ALT_MSGDMA_PREFETCHER_REGS_H_ -#define ALT_MSGDMA_PREFETCHER_REGS_H_ - -#include "io.h" - -/* - MSGDMA Prefetcher core is an additional micro core to existing MSGDMA core which - already consists of dispatcher, read master and write master micro core. Prefetcher - core provides functionality to fetch a series of descriptors from memory that - describes the required data transfers before pass them to dispatcher core for data - transfer execution. -*/ - - -/* - * Component : MSGDMA PREFETCHER - * - */ -#define ALT_MSGDMA_PREFETCHER_CONTROL_OFST 0x00 -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW_OFST 0x04 -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH_OFST 0x08 -#define ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLL_FREQ_OFST 0x0C -#define ALT_MSGDMA_PREFETCHER_STATUS_OFST 0x10 - -/* - * New MSGDMA PREFETCHER Descriptor fields. These are not prefetcher registers - * they are in the prefetcher descriptor structs - */ -/* The mask used to set the ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW value. */ -#define ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW_SET_MASK (1 << 30) -/* The mask used to clear the ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW value. */ -#define ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW_CLR_MASK 0xBFFFFFFF -/* The bit offset of the ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW field. */ -#define ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW_BIT_OFFSET 30 -/* Extracts the ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN field value from a register. */ -#define ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW_GET(value) (((value) & 0x40000000) >> 30) -/* Produces a ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN register field value suitable for setting the register. */ -#define ALT_MSGDMA_PREFETCHER_DESCRIPTOR_CTRL_OWN_BY_HW_SET(value) (((value) << 30) & 0x40000000) - -/* - * Register : control - * - * The control register has two defined bits. - * - * DESC_POLL_EN and RUN . - * - * Detailed description available in their individual bitfields - * - * Register Layout - * - * Bits | Access | Reset | Description - * :-------|:-------|:------|:------------ - * [0] | R/W | 0x0 | RUN - * [1] | R/W | 0x0 | DESC_POLL_EN - * [2] | R/W1S | 0x0 | RESET_PREFETCHER - * [3] | R/W | 0x0 | GLOBAL_INTR_EN_MASK - * [4] | R/W | 0x0 | PARK_MODE - * [31:5] | R | 0x0 | RESERVED - * - */ - -/* bits making up the "control" register */ - -/* the RUN bit field in the control register */ -/* The mask used to set the ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_RUN_SET_MASK 0x1 -/* The mask used to clear the ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_RUN_CLR_MASK 0xFFFFFFFE -/* The bit offset of the ALT_MSGDMA_PREFETCHER_CTRL_RUN register field. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_RUN_BIT_OFFSET 0 -/* Extracts the ALT_MSGDMA_PREFETCHER_CTRL_RUN field value from a register. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_RUN_GET(value) (((value) & 0x00000001) >> 0) -/* Produces a ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value suitable for setting the register. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_RUN_SET(value) (((value) << 0) & 0x00000001) - -/* the DESC_POLL_EN bit field in the control register */ -/* The mask used to set the ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN register field value. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN_MASK 0x2 -/* The mask used to clear the ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN register field value. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN_CLR_MASK 0xFFFFFFFD -/* The bit offset of the ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN register field. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN_BIT_OFFSET 1 -/* Extracts the ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN field value from a register. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN_GET(value) (((value) & 0x00000002) >> 1) -/* Produces a ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN register field value suitable for setting the register. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_DESC_POLL_EN_SET(value) (((value) << 1) & 0x00000002) - -/* the RESET_PREFETCHER bit field in the control register */ -/* The mask used to set the ALT_MSGDMA_PREFETCHER_CTRL_RESET register field value. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_RESET_SET_MASK 0x4 -/* The mask used to clear the ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_RESET_CLR_MASK 0xFFFFFFFB -/* The bit offset of the ALT_MSGDMA_PREFETCHER_CTRL_RUN register field. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_RESET_BIT_OFFSET 2 -/* Extracts the ALT_MSGDMA_PREFETCHER_CTRL_RUN field value from a register. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_RESET_GET(value) (((value) & 0x00000004) >> 2) -/* Produces a ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value suitable for setting the register. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_RESET_SET(value) (((value) << 2) & 0x00000004) - -/* the GLOBAL_INTR_EN_MASK bit field in the control register */ -/* The mask used to set the ALT_MSGDMA_PREFETCHER_CTRL_GLOBAL_INTR_EN_MASK register field value. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_GLOBAL_INTR_EN_SET_MASK 0x8 -/* The mask used to clear the ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_GLOBAL_INTR_EN_CLR_MASK 0xFFFFFFF7 -/* The bit offset of the ALT_MSGDMA_PREFETCHER_CTRL_RUN register field. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_GLOBAL_INTR_EN_BIT_OFFSET 3 -/* Extracts the ALT_MSGDMA_PREFETCHER_CTRL_RUN field value from a register. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_GLOBAL_INTR_EN_GET(value) (((value) & 0x00000008) >> 3) -/* Produces a ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value suitable for setting the register. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_GLOBAL_INTR_EN_SET(value) (((value) << 3) & 0x00000008) - -/* the PARK_MODE bit field in the control register */ -/* The mask used to set the ALT_MSGDMA_PREFETCHER_CTRL_PARK_MODE register field value. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_PARK_MODE_SET_MASK 0x10 -/* The mask used to clear the ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_PARK_MODE_CLR_MASK 0xFFFFFFEF -/* The bit offset of the ALT_MSGDMA_PREFETCHER_CTRL_RUN register field. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_PARK_MODE_BIT_OFFSET 4 -/* Extracts the ALT_MSGDMA_PREFETCHER_CTRL_RUN field value from a register. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_PARK_MODE_GET(value) (((value) & 0x00000010) >> 4) -/* Produces a ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value suitable for setting the register. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_PARK_MODE_SET(value) (((value) << 4) & 0x00000010) - -/* - * Registers : Next Descriptor Pointer Low/High - * - * The register has no bit fields, the 64 bits represent an address. - * - * Register Layout - * - * Bits | Access | Reset | Description - * :-------|:-------|:------|:------------ - * [31:0] | R/W | 0x0 | NEXT_PTR_ADDR_LOW - * [63:32]| R/W | 0x0 | NEXT_PTR_ADDR_HIGH - * - */ - -/* bits making up the "Next Descriptor Pointer " register */ - -/* the NEXT_PTR_ADDR_LOW bit field in the ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW register */ -/* The mask used to set the ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW_REG register field value. */ -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW_SET_MASK 0xFFFFFFFF -/* The mask used to clear the ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_REG register field value. */ -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW_CLR_MASK 0x0 -/* The bit offset of the ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_REG register field. */ -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW_BIT_OFFSET 0 -/* Extracts the ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_REG field value from a register. */ -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW_GET(value) (((value) & 0xFFFFFFFF) >> 0) -/* Produces a ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_REG register field value suitable for setting the register. */ -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW_SET(value) (((value) << 0) & 0xFFFFFFFF) - -/* the NEXT_PTR_ADDR_HIGH bit field in the ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH register */ -/* The mask used to set the ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH_REG register field value. */ -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH_SET_MASK 0xFFFFFFFF -/* The mask used to clear the ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_REG register field value. */ -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH_CLR_MASK 0x0 -/* The bit offset of the ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_REG register field. */ -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH_BIT_OFFSET 0 -/* Extracts the ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_REG field value from a register. */ -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH_GET(value) (((value) & 0xFFFFFFFF) >> 0) -/* Produces a ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_REG register field value suitable for setting the register. */ -#define ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH_SET(value) (((value) << 0) & 0xFFFFFFFF) - - -/* - * Register : Descriptor Polling Frequency - * - * The Descriptor Polling Frequency register has one defined bit field. - * - * POLL_FREQ - * - * Detailed description available in their individual bitfields - * - * Register Layout - * - * Bits | Access | Reset | Description - * :--------|:-------|:------|:------------ - * [15:0] | R/W | 0x0 | POLL_FREQ - * [31:16] | R | 0x0 | RESERVED - * - */ - -/* bits making up the "DESC_POLL_FREQ" register */ - -/* the POLL_FREQ bit field in the ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLL_FREQ register */ -/* The mask used to set the ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLL_FREQ register field value. */ -#define ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLL_FREQ_SET_MASK 0xFFFF -/* The mask used to clear the ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value. */ -#define ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLL_FREQ_CLR_MASK 0xFFFF0000 -/* The bit offset of the ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLL_FREQ register field. */ -#define ALT_MSGDMA_PREFETCHER_CTRL_RUN_BIT_OFFSET 0 -/* Extracts the ALT_MSGDMA_PREFETCHER_CTRL_RUN field value from a register. */ -#define ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLL_FREQ_GET(value) (((value) & 0x0000FFFF) >> 0) -/* Produces a ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value suitable for setting the register. */ -#define ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLL_FREQ_SET(value) (((value) << 0) & 0x0000FFFF) - - -/* - * Register : Status - * - * The Status register has one defined bit field. - * - * IRQ - * - * Detailed description available in their individual bitfields - * - * Register Layout - * - * Bits | Access | Reset | Description - * :--------|:-------|:------|:------------ - * [0] | R/W1C | 0x0 | IRQ - * [31:1] | R | 0x0 | RESERVED - * - */ - -/* bits making up the "STATUS" register */ - -/* the IRQ bit field in the ALT_MSGDMA_PREFETCHER_STATUS register */ -/* The mask used to set the ALT_MSGDMA_PREFETCHER_STATUS_IRQ register field value. */ -#define ALT_MSGDMA_PREFETCHER_STATUS_IRQ_SET_MASK 0x1 -/* The mask used to clear the ALT_MSGDMA_PREFETCHER_STATUS_IRQ register field value. */ -#define ALT_MSGDMA_PREFETCHER_STATUS_IRQ_CLR_MASK 0xFFFFFFFE -/* The bit offset of the ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLL_FREQ register field. */ -#define ALT_MSGDMA_PREFETCHER_STATUS_IRQ_BIT_OFFSET 0 -/* Extracts the ALT_MSGDMA_PREFETCHER_CTRL_RUN field value from a register. */ -#define ALT_MSGDMA_PREFETCHER_STATUS_IRQ_GET(value) (((value) & 0x00000001) >> 0) -/* Produces a ALT_MSGDMA_PREFETCHER_CTRL_RUN register field value suitable for setting the register. */ -#define ALT_MSGDMA_PREFETCHER_STATUS_IRQ_SET(value) (((value) << 0) & 0x00000001) - - - -/*****************************************************************/ -/*** READ/WRITE macros for the MSGDMA PREFETCHER registers ***/ -/*****************************************************************/ -/* ALT_MSGDMA_PREFETCHER_CONTROL_REG */ -#define IORD_ALT_MSGDMA_PREFETCHER_CONTROL(base) \ - IORD_32DIRECT(base, ALT_MSGDMA_PREFETCHER_CONTROL_OFST) -#define IOWR_ALT_MSGDMA_PREFETCHER_CONTROL(base, data) \ - IOWR_32DIRECT(base, ALT_MSGDMA_PREFETCHER_CONTROL_OFST, data) -/* ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW_REG */ -#define IORD_ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW(base) \ - IORD_32DIRECT(base, ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW_OFST) -#define IOWR_ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW(base, data) \ - IOWR_32DIRECT(base, ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_LOW_OFST, data) -/* ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH_REG */ -#define IORD_ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH(base) \ - IORD_32DIRECT(base, ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH_OFST) -#define IOWR_ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH(base, data) \ - IOWR_32DIRECT(base, ALT_MSGDMA_PREFETCHER_NEXT_DESCRIPTOR_PTR_HIGH_OFST, data) -/* ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLLING_FREQ_REG */ -#define IORD_ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLLING_FREQ(base) \ - IORD_32DIRECT(base, ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLL_FREQ_OFST) -#define IOWR_ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLLING_FREQ(base, data) \ - IOWR_32DIRECT(base, ALT_MSGDMA_PREFETCHER_DESCRIPTOR_POLL_FREQ_OFST, data) -/* ALT_MSGDMA_PREFETCHER_STATUS_REG */ -#define IORD_ALT_MSGDMA_PREFETCHER_STATUS(base) \ - IORD_32DIRECT(base, ALT_MSGDMA_PREFETCHER_STATUS_OFST) -#define IOWR_ALT_MSGDMA_PREFETCHER_STATUS(base, data) \ - IOWR_32DIRECT(base, ALT_MSGDMA_PREFETCHER_STATUS_OFST, data) - -#endif /*ALT_MSGDMA_PREFETCHER_REGS_H_*/ diff --git a/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_response_regs.h b/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_response_regs.h deleted file mode 100644 index 4862617198..0000000000 --- a/ext/hal/altera/drivers/altera_msgdma/inc/altera_msgdma_response_regs.h +++ /dev/null @@ -1,66 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2014 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -******************************************************************************/ - -#ifndef ALTERA_MSGDMA_RESPONSE_REGS_H_ -#define ALTERA_MSGDMA_RESPONSE_REGS_H_ - -#include "io.h" - -/* - The response slave port only carries the actual bytes transferred, - error, and early termination bits. Reading from the upper most byte - of the 2nd register pops the response FIFO. For proper FIFO popping - always read the actual bytes transferred followed by the error and early - termination bits using 'little endian' accesses. If a big endian - master accesses the response slave port make sure that address 0x7 is the - last byte lane access as it's the one that pops the reponse FIFO. - - If you use a pre-fetching descriptor master in front of the dispatcher - port then you do not need to access this response slave port. -*/ - - - -#define ALTERA_MSGDMA_RESPONSE_ACTUAL_BYTES_TRANSFERRED_REG 0x0 -#define ALTERA_MSGDMA_RESPONSE_ERRORS_REG 0x4 - -/* bits making up the "errors" register */ -#define ALTERA_MSGDMA_RESPONSE_ERROR_MASK 0xFF -#define ALTERA_MSGDMA_RESPONSE_ERROR_OFFSET 0 -#define ALTERA_MSGDMA_RESPONSE_EARLY_TERMINATION_MASK (1 << 8) -#define ALTERA_MSGDMA_RESPONSE_EARLY_TERMINATION_OFFSET 8 - - -/* read macros for each 32 bit register */ -#define IORD_ALTERA_MSGDMA_RESPONSE_ACTUAL_BYTES_TRANSFERRED(base) \ - IORD_32DIRECT(base, ALTERA_MSGDMA_RESPONSE_ACTUAL_BYTES_TRANSFERRED_REG) -/* this read pops the response FIFO */ -#define IORD_ALTERA_MSGDMA_RESPONSE_ERRORS_REG(base) \ - IORD_32DIRECT(base, ALTERA_MSGDMA_RESPONSE_ERRORS_REG) - - -#endif /*ALTERA_MSGDMA_RESPONSE_REGS_H_*/ diff --git a/ext/hal/altera/include/alt_types.h b/ext/hal/altera/include/alt_types.h deleted file mode 100644 index 683c550a9d..0000000000 --- a/ext/hal/altera/include/alt_types.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __ALT_TYPES_H__ -#define __ALT_TYPES_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/* - * Don't declare these typedefs if this file is included by assembly source. - */ -#ifndef ALT_ASM_SRC -typedef signed char alt_8; -typedef unsigned char alt_u8; -typedef signed short alt_16; -typedef unsigned short alt_u16; -typedef signed long alt_32; -typedef unsigned long alt_u32; -typedef long long alt_64; -typedef unsigned long long alt_u64; -#endif - -#define ALT_INLINE __inline__ -#define ALT_ALWAYS_INLINE __attribute__ ((always_inline)) -#define ALT_WEAK __attribute__((weak)) - -#endif /* __ALT_TYPES_H__ */ diff --git a/ext/hal/altera/include/altera_nios2_gen2_irq.h b/ext/hal/altera/include/altera_nios2_gen2_irq.h deleted file mode 100644 index 38f7212768..0000000000 --- a/ext/hal/altera/include/altera_nios2_gen2_irq.h +++ /dev/null @@ -1,77 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/* - * Support for the Nios II internal interrupt controller. - */ - -#ifndef __ALT_NIOS2_GEN2_IRQ_H__ -#define __ALT_NIOS2_GEN2_IRQ_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * The macro ALTERA_NIOS2_GEN2_IRQ_INSTANCE is used by the alt_irq_init() - * function in the auto-generated file alt_sys_init.c to create an - * instance of this interrupt controller device driver state if this - * module contains an interrupt controller. - * Only one instance of a Nios II is allowed so this macro is just empty. - */ - -#define ALTERA_NIOS2_GEN2_IRQ_INSTANCE(name, state) - -/* - * altera_nios2_gen2_irq_init() is called by the auto-generated function - * alt_irq_init() once for the Nios II if it contains an interrupt controller. - * The altera_nios2_gen2_irq_init() routine is called using the - * ALTERA_NIOS2_GEN2_IRQ_INIT macro given below. - * - * This function initializes the internal interrupt controller - * so is not called if the Nios II contains an external interrupt - * controller port (because the internal interrupt controller - * is removed if this port is present). - */ - -extern void altera_nios2_gen2_irq_init( void ); - -/* - * The macro ALTERA_NIOS2_GEN2_IRQ_INIT is used by the alt_irq_init() routine - * in the auto-generated file alt_sys_init.c to initialize an instance - * of the interrupt controller device driver state. - */ - -#define ALTERA_NIOS2_GEN2_IRQ_INIT(name, state) altera_nios2_gen2_irq_init() - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_NIOS2_ULTRA_IRQ_H__ */ diff --git a/ext/hal/altera/include/io.h b/ext/hal/altera/include/io.h deleted file mode 100644 index 07c55e6e50..0000000000 --- a/ext/hal/altera/include/io.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef __IO_H__ -#define __IO_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -* Altera does not recommend, suggest or require that this reference design * -* file be used in conjunction or combination with any other product. * -******************************************************************************/ - -/* IO Header file for Nios II Toolchain */ - -#include "alt_types.h" -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#ifndef SYSTEM_BUS_WIDTH -#define SYSTEM_BUS_WIDTH 32 -#endif - -/* Dynamic bus access functions */ - -#define __IO_CALC_ADDRESS_DYNAMIC(BASE, OFFSET) \ - ((void *)(((alt_u8*)BASE) + (OFFSET))) - -#define IORD_32DIRECT(BASE, OFFSET) \ - __builtin_ldwio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET))) -#define IORD_16DIRECT(BASE, OFFSET) \ - __builtin_ldhuio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET))) -#define IORD_8DIRECT(BASE, OFFSET) \ - __builtin_ldbuio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET))) - -#define IOWR_32DIRECT(BASE, OFFSET, DATA) \ - __builtin_stwio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET)), (DATA)) -#define IOWR_16DIRECT(BASE, OFFSET, DATA) \ - __builtin_sthio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET)), (DATA)) -#define IOWR_8DIRECT(BASE, OFFSET, DATA) \ - __builtin_stbio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET)), (DATA)) - -/* Native bus access functions */ - -#define __IO_CALC_ADDRESS_NATIVE(BASE, REGNUM) \ - ((void *)(((alt_u8*)BASE) + ((REGNUM) * (SYSTEM_BUS_WIDTH/8)))) - -#define IORD(BASE, REGNUM) \ - __builtin_ldwio (__IO_CALC_ADDRESS_NATIVE ((BASE), (REGNUM))) -#define IOWR(BASE, REGNUM, DATA) \ - __builtin_stwio (__IO_CALC_ADDRESS_NATIVE ((BASE), (REGNUM)), (DATA)) - -#ifdef __cplusplus -} -#endif - -#endif /* __IO_H__ */ diff --git a/ext/hal/altera/include/nios2.h b/ext/hal/altera/include/nios2.h deleted file mode 100644 index 74fc41c4ba..0000000000 --- a/ext/hal/altera/include/nios2.h +++ /dev/null @@ -1,298 +0,0 @@ -#ifndef __NIOS2_H__ -#define __NIOS2_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2008 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/* - * This header provides processor specific macros for accessing the Nios2 - * control registers. - */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * Number of available IRQs in internal interrupt controller. - */ -#define NIOS2_NIRQ 32 - -/* - * Macros for accessing select Nios II general-purpose registers. - */ - -/* ET (Exception Temporary) register */ -#define NIOS2_READ_ET(et) \ - do { __asm ("mov %0, et" : "=r" (et) ); } while (0) - -#define NIOS2_WRITE_ET(et) \ - do { __asm volatile ("mov et, %z0" : : "rM" (et)); } while (0) - -/* SP (Stack Pointer) register */ -#define NIOS2_READ_SP(sp) \ - do { __asm ("mov %0, sp" : "=r" (sp) ); } while (0) - -/* - * Macros for useful processor instructions. - */ -#define NIOS2_BREAK() \ - do { __asm volatile ("break"); } while (0) - -#define NIOS2_REPORT_STACK_OVERFLOW() \ - do { __asm volatile("break 3"); } while (0) - -/* - * Macros for accessing Nios II control registers. - */ -#define NIOS2_READ_STATUS(dest) \ - do { dest = __builtin_rdctl(0); } while (0) - -#define NIOS2_WRITE_STATUS(src) \ - do { __builtin_wrctl(0, src); } while (0) - -#define NIOS2_READ_ESTATUS(dest) \ - do { dest = __builtin_rdctl(1); } while (0) - -#define NIOS2_READ_BSTATUS(dest) \ - do { dest = __builtin_rdctl(2); } while (0) - -#define NIOS2_READ_IENABLE(dest) \ - do { dest = __builtin_rdctl(3); } while (0) - -#define NIOS2_WRITE_IENABLE(src) \ - do { __builtin_wrctl(3, src); } while (0) - -#define NIOS2_READ_IPENDING(dest) \ - do { dest = __builtin_rdctl(4); } while (0) - -#define NIOS2_READ_CPUID(dest) \ - do { dest = __builtin_rdctl(5); } while (0) - -#define NIOS2_READ_EXCEPTION(dest) \ - do { dest = __builtin_rdctl(7); } while (0) - -#define NIOS2_READ_PTEADDR(dest) \ - do { dest = __builtin_rdctl(8); } while (0) - -#define NIOS2_WRITE_PTEADDR(src) \ - do { __builtin_wrctl(8, src); } while (0) - -#define NIOS2_READ_TLBACC(dest) \ - do { dest = __builtin_rdctl(9); } while (0) - -#define NIOS2_WRITE_TLBACC(src) \ - do { __builtin_wrctl(9, src); } while (0) - -#define NIOS2_READ_TLBMISC(dest) \ - do { dest = __builtin_rdctl(10); } while (0) - -#define NIOS2_WRITE_TLBMISC(src) \ - do { __builtin_wrctl(10, src); } while (0) - -#define NIOS2_READ_ECCINJ(dest) \ - do { dest = __builtin_rdctl(11); } while (0) - -#define NIOS2_WRITE_ECCINJ(src) \ - do { __builtin_wrctl(11, src); } while (0) - -#define NIOS2_READ_BADADDR(dest) \ - do { dest = __builtin_rdctl(12); } while (0) - -#define NIOS2_WRITE_CONFIG(src) \ - do { __builtin_wrctl(13, src); } while (0) - -#define NIOS2_READ_CONFIG(dest) \ - do { dest = __builtin_rdctl(13); } while (0) - -#define NIOS2_WRITE_MPUBASE(src) \ - do { __builtin_wrctl(14, src); } while (0) - -#define NIOS2_READ_MPUBASE(dest) \ - do { dest = __builtin_rdctl(14); } while (0) - -#define NIOS2_WRITE_MPUACC(src) \ - do { __builtin_wrctl(15, src); } while (0) - -#define NIOS2_READ_MPUACC(dest) \ - do { dest = __builtin_rdctl(15); } while (0) - -/* - * Nios II control registers that are always present - */ -#define NIOS2_STATUS status -#define NIOS2_ESTATUS estatus -#define NIOS2_BSTATUS bstatus -#define NIOS2_IENABLE ienable -#define NIOS2_IPENDING ipending -#define NIOS2_CPUID cpuid - -/* - * Bit masks & offsets for Nios II control registers. - * The presence and size of a field is sometimes dependent on the Nios II - * configuration. Bit masks for every possible field and the maximum size of - * that field are defined. - * - * All bit-masks are expressed relative to the position - * of the data with a register. To read data that is LSB- - * aligned, the register read data should be masked, then - * right-shifted by the designated "OFST" macro value. The - * opposite should be used for register writes when starting - * with LSB-aligned data. - */ - -/* STATUS, ESTATUS, BSTATUS, and SSTATUS registers */ -#define NIOS2_STATUS_PIE_MSK (0x00000001) -#define NIOS2_STATUS_PIE_OFST (0) -#define NIOS2_STATUS_U_MSK (0x00000002) -#define NIOS2_STATUS_U_OFST (1) -#define NIOS2_STATUS_EH_MSK (0x00000004) -#define NIOS2_STATUS_EH_OFST (2) -#define NIOS2_STATUS_IH_MSK (0x00000008) -#define NIOS2_STATUS_IH_OFST (3) -#define NIOS2_STATUS_IL_MSK (0x000003f0) -#define NIOS2_STATUS_IL_OFST (4) -#define NIOS2_STATUS_CRS_MSK (0x0000fc00) -#define NIOS2_STATUS_CRS_OFST (10) -#define NIOS2_STATUS_PRS_MSK (0x003f0000) -#define NIOS2_STATUS_PRS_OFST (16) -#define NIOS2_STATUS_NMI_MSK (0x00400000) -#define NIOS2_STATUS_NMI_OFST (22) -#define NIOS2_STATUS_RSIE_MSK (0x00800000) -#define NIOS2_STATUS_RSIE_OFST (23) -#define NIOS2_STATUS_SRS_MSK (0x80000000) -#define NIOS2_STATUS_SRS_OFST (31) - -/* EXCEPTION register */ -#define NIOS2_EXCEPTION_REG_CAUSE_MASK (0x0000007c) -#define NIOS2_EXCEPTION_REG_CAUSE_OFST (2) -#define NIOS2_EXCEPTION_REG_ECCFTL_MASK (0x80000000) -#define NIOS2_EXCEPTION_REG_ECCFTL_OFST (31) - -/* PTEADDR (Page Table Entry Address) register */ -#define NIOS2_PTEADDR_REG_VPN_OFST 2 -#define NIOS2_PTEADDR_REG_VPN_MASK 0x3ffffc -#define NIOS2_PTEADDR_REG_PTBASE_OFST 22 -#define NIOS2_PTEADDR_REG_PTBASE_MASK 0xffc00000 - -/* TLBACC (TLB Access) register */ -#define NIOS2_TLBACC_REG_PFN_OFST 0 -#define NIOS2_TLBACC_REG_PFN_MASK 0xfffff -#define NIOS2_TLBACC_REG_G_OFST 20 -#define NIOS2_TLBACC_REG_G_MASK 0x100000 -#define NIOS2_TLBACC_REG_X_OFST 21 -#define NIOS2_TLBACC_REG_X_MASK 0x200000 -#define NIOS2_TLBACC_REG_W_OFST 22 -#define NIOS2_TLBACC_REG_W_MASK 0x400000 -#define NIOS2_TLBACC_REG_R_OFST 23 -#define NIOS2_TLBACC_REG_R_MASK 0x800000 -#define NIOS2_TLBACC_REG_C_OFST 24 -#define NIOS2_TLBACC_REG_C_MASK 0x1000000 -#define NIOS2_TLBACC_REG_IG_OFST 25 -#define NIOS2_TLBACC_REG_IG_MASK 0xfe000000 - -/* TLBMISC (TLB Miscellaneous) register */ -#define NIOS2_TLBMISC_REG_D_OFST 0 -#define NIOS2_TLBMISC_REG_D_MASK 0x1 -#define NIOS2_TLBMISC_REG_PERM_OFST 1 -#define NIOS2_TLBMISC_REG_PERM_MASK 0x2 -#define NIOS2_TLBMISC_REG_BAD_OFST 2 -#define NIOS2_TLBMISC_REG_BAD_MASK 0x4 -#define NIOS2_TLBMISC_REG_DBL_OFST 3 -#define NIOS2_TLBMISC_REG_DBL_MASK 0x8 -#define NIOS2_TLBMISC_REG_PID_OFST 4 -#define NIOS2_TLBMISC_REG_PID_MASK 0x3fff0 -#define NIOS2_TLBMISC_REG_WE_OFST 18 -#define NIOS2_TLBMISC_REG_WE_MASK 0x40000 -#define NIOS2_TLBMISC_REG_RD_OFST 19 -#define NIOS2_TLBMISC_REG_RD_MASK 0x80000 -#define NIOS2_TLBMISC_REG_WAY_OFST 20 -#define NIOS2_TLBMISC_REG_WAY_MASK 0xf00000 -#define NIOS2_TLBMISC_REG_EE_OFST 24 -#define NIOS2_TLBMISC_REG_EE_MASK 0x1000000 - -/* ECCINJ (ECC Inject) register */ -#define NIOS2_ECCINJ_REG_RF_OFST 0 -#define NIOS2_ECCINJ_REG_RF_MASK 0x3 -#define NIOS2_ECCINJ_REG_ICTAG_OFST 2 -#define NIOS2_ECCINJ_REG_ICTAG_MASK 0xc -#define NIOS2_ECCINJ_REG_ICDAT_OFST 4 -#define NIOS2_ECCINJ_REG_ICDAT_MASK 0x30 -#define NIOS2_ECCINJ_REG_DCTAG_OFST 6 -#define NIOS2_ECCINJ_REG_DCTAG_MASK 0xc0 -#define NIOS2_ECCINJ_REG_DCDAT_OFST 8 -#define NIOS2_ECCINJ_REG_DCDAT_MASK 0x300 -#define NIOS2_ECCINJ_REG_TLB_OFST 10 -#define NIOS2_ECCINJ_REG_TLB_MASK 0xc00 -#define NIOS2_ECCINJ_REG_DTCM0_OFST 12 -#define NIOS2_ECCINJ_REG_DTCM0_MASK 0x3000 -#define NIOS2_ECCINJ_REG_DTCM1_OFST 14 -#define NIOS2_ECCINJ_REG_DTCM1_MASK 0xc000 -#define NIOS2_ECCINJ_REG_DTCM2_OFST 16 -#define NIOS2_ECCINJ_REG_DTCM2_MASK 0x30000 -#define NIOS2_ECCINJ_REG_DTCM3_OFST 18 -#define NIOS2_ECCINJ_REG_DTCM3_MASK 0xc0000 - -/* CONFIG register */ -#define NIOS2_CONFIG_REG_PE_MASK (0x00000001) -#define NIOS2_CONFIG_REG_PE_OFST (0) -#define NIOS2_CONFIG_REG_ANI_MASK (0x00000002) -#define NIOS2_CONFIG_REG_ANI_OFST (1) -#define NIOS2_CONFIG_REG_ECCEN_MASK (0x00000004) -#define NIOS2_CONFIG_REG_ECCEN_OFST (2) -#define NIOS2_CONFIG_REG_ECCEXC_MASK (0x00000008) -#define NIOS2_CONFIG_REG_ECCEXC_OFST (3) - -/* MPUBASE (MPU Base Address) Register */ -#define NIOS2_MPUBASE_D_MASK (0x00000001) -#define NIOS2_MPUBASE_D_OFST (0) -#define NIOS2_MPUBASE_INDEX_MASK (0x0000003e) -#define NIOS2_MPUBASE_INDEX_OFST (1) -#define NIOS2_MPUBASE_BASE_ADDR_MASK (0xffffffc0) -#define NIOS2_MPUBASE_BASE_ADDR_OFST (6) - -/* MPUACC (MPU Access) Register */ -#define NIOS2_MPUACC_LIMIT_MASK (0xffffffc0) -#define NIOS2_MPUACC_LIMIT_OFST (6) -#define NIOS2_MPUACC_MASK_MASK (0xffffffc0) -#define NIOS2_MPUACC_MASK_OFST (6) -#define NIOS2_MPUACC_C_MASK (0x00000020) -#define NIOS2_MPUACC_C_OFST (5) -#define NIOS2_MPUACC_PERM_MASK (0x0000001c) -#define NIOS2_MPUACC_PERM_OFST (2) -#define NIOS2_MPUACC_RD_MASK (0x00000002) -#define NIOS2_MPUACC_RD_OFST (1) -#define NIOS2_MPUACC_WR_MASK (0x00000001) -#define NIOS2_MPUACC_WR_OFST (0) - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __NIOS2_H__ */ diff --git a/ext/hal/altera/include/priv/alt_busy_sleep.h b/ext/hal/altera/include/priv/alt_busy_sleep.h deleted file mode 100644 index b1af849991..0000000000 --- a/ext/hal/altera/include/priv/alt_busy_sleep.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __ALT_BUSY_SLEEP_H -#define __ALT_BUSY_SLEEP_H - -/* - * Copyright (c) 2003 Altera Corporation, San Jose, California, USA. - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/* - * The function alt_busy_sleep provides a busy loop implementation of usleep. - * This is used to provide usleep for the standalone HAL, or when the timer is - * unavailable in uC/OS-II. - */ - -extern unsigned int alt_busy_sleep (unsigned int us); - -#endif /* __ALT_BUSY_SLEEP_H */ diff --git a/ext/hal/altera/include/priv/alt_legacy_irq.h b/ext/hal/altera/include/priv/alt_legacy_irq.h deleted file mode 100644 index cb966f33c3..0000000000 --- a/ext/hal/altera/include/priv/alt_legacy_irq.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef __ALT_LEGACY_IRQ_H__ -#define __ALT_LEGACY_IRQ_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/* - * This file provides prototypes and inline implementations of certain routines - * used by the legacy interrupt API. Do not include this in your driver or - * application source files, use "sys/alt_irq.h" instead to access the proper - * public API. - */ - -#include -#include "system.h" - -#ifndef NIOS2_EIC_PRESENT - -#include "nios2.h" -#include "alt_types.h" - -#include "sys/alt_irq.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * alt_irq_register() can be used to register an interrupt handler. If the - * function is succesful, then the requested interrupt will be enabled upon - * return. - */ -extern int alt_irq_register (alt_u32 id, - void* context, - alt_isr_func handler); - -/* - * alt_irq_disable() disables the individual interrupt indicated by "id". - */ -static ALT_INLINE int ALT_ALWAYS_INLINE alt_irq_disable (alt_u32 id) -{ - alt_irq_context status; - extern volatile alt_u32 alt_irq_active; - - status = alt_irq_disable_all (); - - alt_irq_active &= ~(1 << id); - NIOS2_WRITE_IENABLE (alt_irq_active); - - alt_irq_enable_all(status); - - return 0; -} - -/* - * alt_irq_enable() enables the individual interrupt indicated by "id". - */ -static ALT_INLINE int ALT_ALWAYS_INLINE alt_irq_enable (alt_u32 id) -{ - alt_irq_context status; - extern volatile alt_u32 alt_irq_active; - - status = alt_irq_disable_all (); - - alt_irq_active |= (1 << id); - NIOS2_WRITE_IENABLE (alt_irq_active); - - alt_irq_enable_all(status); - - return 0; -} - -#ifndef ALT_EXCEPTION_STACK -/* - * alt_irq_initerruptable() should only be called from within an ISR. It is used - * to allow higer priority interrupts to interrupt the current ISR. The input - * argument, "priority", is the priority, i.e. interrupt number of the current - * interrupt. - * - * If this function is called, then the ISR is required to make a call to - * alt_irq_non_interruptible() before returning. The input argument to - * alt_irq_non_interruptible() is the return value from alt_irq_interruptible(). - * - * Care should be taken when using this pair of functions, since they increasing - * the system overhead associated with interrupt handling. - * - * If you are using an exception stack then nested interrupts won't work, so - * these functions are not available in that case. - */ -static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_irq_interruptible (alt_u32 priority) -{ - extern volatile alt_u32 alt_priority_mask; - extern volatile alt_u32 alt_irq_active; - - alt_u32 old_priority; - - old_priority = alt_priority_mask; - alt_priority_mask = (1 << priority) - 1; - - NIOS2_WRITE_IENABLE (alt_irq_active & alt_priority_mask); - - NIOS2_WRITE_STATUS (1); - - return old_priority; -} - -/* - * See Comments above for alt_irq_interruptible() for an explanation of the use of this - * function. - */ -static ALT_INLINE void ALT_ALWAYS_INLINE alt_irq_non_interruptible (alt_u32 mask) -{ - extern volatile alt_u32 alt_priority_mask; - extern volatile alt_u32 alt_irq_active; - - NIOS2_WRITE_STATUS (0); - - alt_priority_mask = mask; - - NIOS2_WRITE_IENABLE (mask & alt_irq_active); -} -#endif /* ALT_EXCEPTION_STACK */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* NIOS2_EIC_PRESENT */ - -#endif /* __ALT_LEGACY_IRQ_H__ */ diff --git a/ext/hal/altera/include/priv/nios2_gmon_data.h b/ext/hal/altera/include/priv/nios2_gmon_data.h deleted file mode 100644 index c4641e65f8..0000000000 --- a/ext/hal/altera/include/priv/nios2_gmon_data.h +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ -#ifndef NIOS2_GMON_DATA_H -#define NIOS2_GMON_DATA_H - -#define GMON_DATA_SIG 0 -#define GMON_DATA_WORDS 1 -#define GMON_DATA_PROFILE_DATA 2 -#define GMON_DATA_PROFILE_LOWPC 3 -#define GMON_DATA_PROFILE_HIGHPC 4 -#define GMON_DATA_PROFILE_BUCKET 5 -#define GMON_DATA_PROFILE_RATE 6 -#define GMON_DATA_MCOUNT_START 7 -#define GMON_DATA_MCOUNT_LIMIT 8 - -#define GMON_DATA_SIZE 9 - -extern unsigned int alt_gmon_data[GMON_DATA_SIZE]; - -#endif diff --git a/ext/hal/altera/include/sys/alt_debug.h b/ext/hal/altera/include/sys/alt_debug.h deleted file mode 100644 index 24755726dd..0000000000 --- a/ext/hal/altera/include/sys/alt_debug.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef __ALT_DEBUG_H__ -#define __ALT_DEBUG_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/* - * The ALT_DEVUG_ASSERT macro can be used to generate a debugger break - * from within software. The break is generated if "condition" evaluates to - * false. - */ - -#define ALT_DEBUG_ASSERT(condition) if (!condition) \ -{ \ - __asm__ volatile ("break"); \ -} - -#endif /* __ALT_DEBUG_H__ */ diff --git a/ext/hal/altera/include/sys/alt_exceptions.h b/ext/hal/altera/include/sys/alt_exceptions.h deleted file mode 100644 index 5e280845cf..0000000000 --- a/ext/hal/altera/include/sys/alt_exceptions.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef __ALT_EXCEPTIONS_H__ -#define __ALT_EXCEPTIONS_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2008 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ -#include "alt_types.h" -#include "system.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * This file defines instruction-generated exception handling and registry - * API, exception type enumeration, and handler return value enumeration for - * Nios II. - */ - -/* - * The following enumeration describes the value in the CPU EXCEPTION - * register CAUSE bit field. - */ -enum alt_exception_cause_e { - /* - * This value is passed to an exception handler's cause argument if - * "extra exceptions" information (EXECPTION) register is not - * present in the processor hardware configuration. - */ - NIOS2_EXCEPTION_CAUSE_NOT_PRESENT = -1, - - /* - * Real values - */ - NIOS2_EXCEPTION_RESET = 0, - NIOS2_EXCEPTION_CPU_ONLY_RESET_REQUEST = 1, - NIOS2_EXCEPTION_INTERRUPT = 2, - NIOS2_EXCEPTION_TRAP_INST = 3, - NIOS2_EXCEPTION_UNIMPLEMENTED_INST = 4, - NIOS2_EXCEPTION_ILLEGAL_INST = 5, - NIOS2_EXCEPTION_MISALIGNED_DATA_ADDR = 6, - NIOS2_EXCEPTION_MISALIGNED_TARGET_PC = 7, - NIOS2_EXCEPTION_DIVISION_ERROR = 8, - NIOS2_EXCEPTION_SUPERVISOR_ONLY_INST_ADDR = 9, - NIOS2_EXCEPTION_SUPERVISOR_ONLY_INST = 10, - NIOS2_EXCEPTION_SUPERVISOR_ONLY_DATA_ADDR = 11, - NIOS2_EXCEPTION_TLB_MISS = 12, - NIOS2_EXCEPTION_TLB_EXECUTE_PERM_VIOLATION = 13, - NIOS2_EXCEPTION_TLB_READ_PERM_VIOLATION = 14, - NIOS2_EXCEPTION_TLB_WRITE_PERM_VIOLATION = 15, - NIOS2_EXCEPTION_MPU_INST_REGION_VIOLATION = 16, - NIOS2_EXCEPTION_MPU_DATA_REGION_VIOLATION = 17, - NIOS2_EXCEPTION_ECC_TLB_ERR = 18, - NIOS2_EXCEPTION_ECC_FETCH_ERR = 19, - NIOS2_EXCEPTION_ECC_REGISTER_FILE_ERR = 20, - NIOS2_EXCEPTION_ECC_DATA_ERR = 21, - NIOS2_EXCEPTION_ECC_DATA_CACHE_WRITEBACK_ERR = 22 -}; -typedef enum alt_exception_cause_e alt_exception_cause; - -/* - * These define valid return values for a user-defined instruction-generated - * exception handler. The handler should return one of these to indicate - * whether to re-issue the instruction that triggered the exception, or to - * skip it. - */ -enum alt_exception_result_e { - NIOS2_EXCEPTION_RETURN_REISSUE_INST = 0, - NIOS2_EXCEPTION_RETURN_SKIP_INST = 1 -}; -typedef enum alt_exception_result_e alt_exception_result; - -/* - * alt_instruction_exception_register() can be used to register an exception - * handler for instruction-generated exceptions that are not handled by the - * built-in exception handler (i.e. for interrupts). - * - * The registry API is optionally enabled through the "Enable - * Instruction-related Exception API" HAL BSP setting, which will - * define the macro below. - */ -#ifdef ALT_INCLUDE_INSTRUCTION_RELATED_EXCEPTION_API -void alt_instruction_exception_register ( - alt_exception_result (*exception_handler)( - alt_exception_cause cause, - alt_u32 exception_pc, - alt_u32 bad_addr) ); -#endif /*ALT_INCLUDE_INSTRUCTION_RELATED_EXCEPTION_API */ - -/* - * alt_exception_cause_generated_bad_addr() indicates whether a particular - * exception cause value was from an exception-type that generated a valid - * address in the BADADDR register. The contents of BADADDR is passed to - * a user-registered exception handler in all cases, whether valid or not. - * This routine should be called to validate the bad_addr argument to - * your exception handler. - * - * Note that this routine will return false (0) for causes - * NIOS2_EXCEPTION_TLB_MISS and NIOS2_EXCEPTION_ECC_TLB_ERR. - * You must read the TLBMISC.D field to determine if BADADDR - * is valid for these (valid if TLBMISC.D = 1). - */ -int alt_exception_cause_generated_bad_addr(alt_exception_cause cause); - -/* - * alt_ecc_fatal_exception_register() is called to register a handler to - * service likely fatal ECC error exceptions. Likely the handler will - * assume that correct execution of the running software is not possible - * and re-initialize the processor (e.g. jump to reset address). - * - * Passing null (0x0) in the handler argument will disable a previously- - * registered handler. - * - * Note that if no handler is registered, just normal exception processing - * occurs on a likely fatal ECC exception and the exception processing - * code might trigger an infinite exception loop. - * - * Note that the handler isn't a C function: it must be written in - * assembly-code because it doesn't support C language calling conventions - * and it can't return. - * - * The handler code must be carefully written to avoid triggering - * another fatal ECC exception and creating an infinite exception loop. - * The handler must avoid reading registers in case the fatal ECC - * error is a register file ECC error. - * If a data cache is present, the handler must avoid instructions that - * access the data cache in case the fatal ECC error is a data cache - * related ECC error. This includes cacheable load, cacheable store, - * non-cacheable store (because it looks in the data cache to update the - * data cache if it hits), and all data cache management instructions except - * for INITD. - */ -void alt_ecc_fatal_exception_register(alt_u32 handler); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_EXCEPTIONS_H__ */ diff --git a/ext/hal/altera/include/sys/alt_irq.h b/ext/hal/altera/include/sys/alt_irq.h deleted file mode 100644 index de937de73c..0000000000 --- a/ext/hal/altera/include/sys/alt_irq.h +++ /dev/null @@ -1,243 +0,0 @@ -#ifndef __ALT_IRQ_H__ -#define __ALT_IRQ_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/* - * alt_irq.h is the Nios II specific implementation of the interrupt controller - * interface. - * - * Nios II includes optional support for an external interrupt controller. - * When an external controller is present, the "Enhanced" interrupt API - * must be used to manage individual interrupts. The enhanced API also - * supports the processor's internal interrupt controller. Certain API - * members are accessible from either the "legacy" or "enhanced" interrpt - * API. - * - * Regardless of which API is in use, this file should be included by - * application code and device drivers that register ISRs or manage interrpts. - */ -#include - -#include "nios2.h" -#include "alt_types.h" -#include "system.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * Macros used by alt_irq_enabled - */ -#define ALT_IRQ_ENABLED 1 -#define ALT_IRQ_DISABLED 0 - -/* - * Number of available interrupts in internal interrupt controller. - */ -#define ALT_NIRQ NIOS2_NIRQ - -/* - * Used by alt_irq_disable_all() and alt_irq_enable_all(). - */ -typedef int alt_irq_context; - -/* ISR Prototype */ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT -typedef void (*alt_isr_func)(void* isr_context); -#else -typedef void (*alt_isr_func)(void* isr_context, alt_u32 id); -#endif - -/* - * The following protypes and routines are supported by both - * the enhanced and legacy interrupt APIs - */ - -/* - * alt_irq_enabled can be called to determine if the processor's global - * interrupt enable is asserted. The return value is zero if interrupts - * are disabled, and non-zero otherwise. - * - * Whether the internal or external interrupt controller is present, - * individual interrupts may still be disabled. Use the other API to query - * a specific interrupt. - */ -static ALT_INLINE int ALT_ALWAYS_INLINE alt_irq_enabled (void) -{ - int status; - - NIOS2_READ_STATUS (status); - - return status & NIOS2_STATUS_PIE_MSK; -} - -/* - * alt_irq_disable_all() - * - * This routine inhibits all interrupts by negating the status register PIE - * bit. It returns the previous contents of the CPU status register (IRQ - * context) which can be used to restore the status register PIE bit to its - * state before this routine was called. - */ -static ALT_INLINE alt_irq_context ALT_ALWAYS_INLINE - alt_irq_disable_all (void) -{ - alt_irq_context context; - - NIOS2_READ_STATUS (context); - - NIOS2_WRITE_STATUS (context & ~NIOS2_STATUS_PIE_MSK); - - return context; -} - -/* - * alt_irq_enable_all() - * - * Enable all interrupts that were previously disabled by alt_irq_disable_all() - * - * This routine accepts a context to restore the CPU status register PIE bit - * to the state prior to a call to alt_irq_disable_all(). - - * In the case of nested calls to alt_irq_disable_all()/alt_irq_enable_all(), - * this means that alt_irq_enable_all() does not necessarily re-enable - * interrupts. - * - * This routine will perform a read-modify-write sequence to restore only - * status.PIE if the processor is configured with options that add additional - * writeable status register bits. These include the MMU, MPU, the enhanced - * interrupt controller port, and shadow registers. Otherwise, as a performance - * enhancement, status is overwritten with the prior context. - */ -static ALT_INLINE void ALT_ALWAYS_INLINE - alt_irq_enable_all (alt_irq_context context) -{ -#if (NIOS2_NUM_OF_SHADOW_REG_SETS > 0) || (defined NIOS2_EIC_PRESENT) || \ - (defined NIOS2_MMU_PRESENT) || (defined NIOS2_MPU_PRESENT) - alt_irq_context status; - - NIOS2_READ_STATUS (status); - - status &= ~NIOS2_STATUS_PIE_MSK; - status |= (context & NIOS2_STATUS_PIE_MSK); - - NIOS2_WRITE_STATUS (status); -#else - NIOS2_WRITE_STATUS (context); -#endif -} - -/* - * The function alt_irq_init() is defined within the auto-generated file - * alt_sys_init.c. This function calls the initilization macros for all - * interrupt controllers in the system at config time, before any other - * non-interrupt controller driver is initialized. - * - * The "base" parameter is ignored and only present for backwards-compatibility. - * It is recommended that NULL is passed in for the "base" parameter. - */ -extern void alt_irq_init (const void* base); - -/* - * alt_irq_cpu_enable_interrupts() enables the CPU to start taking interrupts. - */ -static ALT_INLINE void ALT_ALWAYS_INLINE - alt_irq_cpu_enable_interrupts (void) -{ - NIOS2_WRITE_STATUS(NIOS2_STATUS_PIE_MSK -#if defined(NIOS2_EIC_PRESENT) && (NIOS2_NUM_OF_SHADOW_REG_SETS > 0) - | NIOS2_STATUS_RSIE_MSK -#endif - ); -} - - -/* - * Prototypes for the enhanced interrupt API. - */ -#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT -/* - * alt_ic_isr_register() can be used to register an interrupt handler. If the - * function is succesful, then the requested interrupt will be enabled upon - * return. - */ -extern int alt_ic_isr_register(alt_u32 ic_id, - alt_u32 irq, - alt_isr_func isr, - void *isr_context, - void *flags); - -/* - * alt_ic_irq_enable() and alt_ic_irq_disable() enable/disable a specific - * interrupt by using IRQ port and interrupt controller instance. - */ -int alt_ic_irq_enable (alt_u32 ic_id, alt_u32 irq); -int alt_ic_irq_disable(alt_u32 ic_id, alt_u32 irq); - - /* - * alt_ic_irq_enabled() indicates whether a specific interrupt, as - * specified by IRQ port and interrupt controller instance is enabled. - */ -alt_u32 alt_ic_irq_enabled(alt_u32 ic_id, alt_u32 irq); - -#else -/* - * Prototypes for the legacy interrupt API. - */ -#include "priv/alt_legacy_irq.h" -#endif - - -/* - * alt_irq_pending() returns a bit list of the current pending interrupts. - * This is used by alt_irq_handler() to determine which registered interrupt - * handlers should be called. - * - * This routine is only available for the Nios II internal interrupt - * controller. - */ -#ifndef NIOS2_EIC_PRESENT -static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_irq_pending (void) -{ - alt_u32 active; - - NIOS2_READ_IPENDING (active); - - return active; -} -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_IRQ_H__ */ diff --git a/ext/hal/altera/include/sys/alt_irq_entry.h b/ext/hal/altera/include/sys/alt_irq_entry.h deleted file mode 100644 index c2f3cfc2ed..0000000000 --- a/ext/hal/altera/include/sys/alt_irq_entry.h +++ /dev/null @@ -1,36 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/* - * This file pulls in the IRQ entry assembler and C code, which is only - * required if there are any interruptes in the system. - */ - -__asm__( "\n\t.globl alt_irq_entry" ); - -__asm__( "\n\t.globl alt_irq_handler" ); diff --git a/ext/hal/altera/include/sys/alt_sim.h b/ext/hal/altera/include/sys/alt_sim.h deleted file mode 100644 index 51554421ad..0000000000 --- a/ext/hal/altera/include/sys/alt_sim.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef __ALT_SIM_H__ -#define __ALT_SIM_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2007 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ -#include "system.h" -#include "alt_types.h" - -/* - * Instructions that might mean something special to a simulator. - * These have no special effect on real hardware (they are just nops). - */ -#define ALT_SIM_FAIL() \ - do { __asm volatile ("cmpltui r0, r0, 0xabc1"); } while (0) - -#define ALT_SIM_PASS() \ - do { __asm volatile ("cmpltui r0, r0, 0xabc2"); } while (0) - -#define ALT_SIM_IN_TOP_OF_HOT_LOOP() \ - do { __asm volatile ("cmpltui r0, r0, 0xabc3"); } while (0) - -/* - * Routine called on exit. - */ -static ALT_INLINE ALT_ALWAYS_INLINE void alt_sim_halt(int exit_code) -{ - register int r2 asm ("r2") = exit_code; - -#if defined(NIOS2_HAS_DEBUG_STUB) && (defined(ALT_BREAK_ON_EXIT) || defined(ALT_PROVIDE_GMON)) - - register int r3 asm ("r3") = (1 << 2); - -#ifdef ALT_PROVIDE_GMON - extern unsigned int alt_gmon_data[]; - register int r4 asm ("r4") = (int)alt_gmon_data; - r3 |= (1 << 4); -#define ALT_GMON_DATA ,"r"(r4) -#else -#define ALT_GMON_DATA -#endif /* ALT_PROVIDE_GMON */ - - if (r2) { - ALT_SIM_FAIL(); - } else { - ALT_SIM_PASS(); - } - - __asm__ volatile ("\n0:\n\taddi %0,%0, -1\n\tbgt %0,zero,0b" : : "r" (ALT_CPU_FREQ/100) ); /* Delay for >30ms */ - - __asm__ volatile ("break 2" : : "r"(r2), "r"(r3) ALT_GMON_DATA ); - -#else /* !DEBUG_STUB */ - if (r2) { - ALT_SIM_FAIL(); - } else { - ALT_SIM_PASS(); - } -#endif /* DEBUG_STUB */ -} - -#define ALT_SIM_HALT(exit_code) \ - alt_sim_halt(exit_code) - -#endif /* __ALT_SIM_H__ */ diff --git a/ext/hal/altera/include/sys/alt_stack.h b/ext/hal/altera/include/sys/alt_stack.h deleted file mode 100644 index fa6a240d2c..0000000000 --- a/ext/hal/altera/include/sys/alt_stack.h +++ /dev/null @@ -1,123 +0,0 @@ -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -#ifndef __ALT_STACK_H__ -#define __ALT_STACK_H__ - -/* - * alt_stack.h is the nios2 specific implementation of functions used by the - * stack overflow code. - */ - -#include "nios2.h" - -#include "alt_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - - -extern char * alt_stack_limit_value; - -#ifdef ALT_EXCEPTION_STACK -extern char __alt_exception_stack_pointer[]; /* set by the linker */ -#endif /* ALT_EXCEPTION_STACK */ - - -/* - * alt_stack_limit can be called to determine the current value of the stack - * limit register. - */ - -static ALT_INLINE char * ALT_ALWAYS_INLINE alt_stack_limit (void) -{ - char * limit; - NIOS2_READ_ET(limit); - - return limit; -} - -/* - * alt_stack_pointer can be called to determine the current value of the stack - * pointer register. - */ - -static ALT_INLINE char * ALT_ALWAYS_INLINE alt_stack_pointer (void) -{ - char * pointer; - NIOS2_READ_SP(pointer); - - return pointer; -} - - -#ifdef ALT_EXCEPTION_STACK - -/* - * alt_exception_stack_pointer returns the normal stack pointer from - * where it is stored on the exception stack (uppermost 4 bytes). This - * is really only useful during exception processing, and is only - * available if a separate exception stack has been configured. - */ - -static ALT_INLINE char * ALT_ALWAYS_INLINE alt_exception_stack_pointer (void) -{ - return (char *) *(alt_u32 *)(__alt_exception_stack_pointer - sizeof(alt_u32)); -} - -#endif /* ALT_EXCEPTION_STACK */ - - -/* - * alt_set_stack_limit can be called to update the current value of the stack - * limit register. - */ - -static ALT_INLINE void ALT_ALWAYS_INLINE alt_set_stack_limit (char * limit) -{ - alt_stack_limit_value = limit; - NIOS2_WRITE_ET(limit); -} - -/* - * alt_report_stack_overflow reports that a stack overflow happened. - */ - -static ALT_INLINE void ALT_ALWAYS_INLINE alt_report_stack_overflow (void) -{ - NIOS2_REPORT_STACK_OVERFLOW(); -} - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ALT_STACK_H__ */ diff --git a/ext/hal/altera/include/sys/alt_warning.h b/ext/hal/altera/include/sys/alt_warning.h deleted file mode 100644 index 24bbeeaffe..0000000000 --- a/ext/hal/altera/include/sys/alt_warning.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef __WARNING_H__ -#define __WARNING_H__ - -/****************************************************************************** -* * -* License Agreement * -* * -* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * -* All rights reserved. * -* * -* Permission is hereby granted, free of charge, to any person obtaining a * -* copy of this software and associated documentation files (the "Software"), * -* to deal in the Software without restriction, including without limitation * -* the rights to use, copy, modify, merge, publish, distribute, sublicense, * -* and/or sell copies of the Software, and to permit persons to whom the * -* Software is furnished to do so, subject to the following conditions: * -* * -* The above copyright notice and this permission notice shall be included in * -* all copies or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * -* DEALINGS IN THE SOFTWARE. * -* * -* * -******************************************************************************/ - -/* - * alt_warning.h provides macro definitions that can be used to generate link - * time warnings. - */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * The symbol "__alt_invalid" is used to force a link error. There should be - * no corresponding implementation of this function. - */ - -extern void __alt_invalid (void); - -#define ALT_LINK_WARNING(symbol, msg) \ - __asm__(".ifndef __evoke_link_warning_" #symbol \ - "\n\t .section .gnu.warning." #symbol \ - "\n__evoke_link_warning_" #symbol ":\n\t .string \x22" msg "\x22 \n\t .previous" \ - "\n .endif"); - -/* A canned warning for sysdeps/stub functions. */ - -#define ALT_STUB_WARNING(name) \ - ALT_LINK_WARNING (name, \ - "warning: " #name " is not implemented and will always fail") - -#define ALT_OBSOLETE_FUNCTION_WARNING(name) \ - ALT_LINK_WARNING (name, \ - "warning: " #name " is a deprecated function") - -#define ALT_LINK_ERROR(msg) \ - ALT_LINK_WARNING (__alt_invalid, msg); \ - __alt_invalid() - -#ifdef __cplusplus -} -#endif - -#endif /* __WARNING_H__ */ diff --git a/modules/Kconfig b/modules/Kconfig index a534efbf27..d106078af1 100644 --- a/modules/Kconfig +++ b/modules/Kconfig @@ -3,6 +3,7 @@ comment "Optional modules. Make sure they're installed, via the project manifest." +source "modules/Kconfig.altera" source "modules/Kconfig.atmel" source "modules/Kconfig.canopennode" source "modules/Kconfig.civetweb" diff --git a/ext/hal/altera/Kconfig b/modules/Kconfig.altera similarity index 100% rename from ext/hal/altera/Kconfig rename to modules/Kconfig.altera diff --git a/west.yml b/west.yml index 08745b91ec..5c594dafd4 100644 --- a/west.yml +++ b/west.yml @@ -31,6 +31,9 @@ manifest: - name: hal_atmel revision: 5a44c9d54dffd685fb6664a646922cfe41c5cf8e path: modules/hal/atmel + - name: hal_altera + revision: 23c1c1dd7a0c1cc9a399509d1819375847c95b97 + path: modules/hal/altera - name: canopennode path: modules/lib/canopennode revision: 5c6b0566d56264efd4bf23ed58bc7cb8b32fe063