Fic8120 Linux Pg V0

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Fic8120 Linux Pg V0 as PDF for free.

More details

  • Words: 17,578
  • Pages: 151
FIC8120

MDC1 RISC-B ASED P LATFORM Programming Guide Rev.: 0.6 Issue Date: Aug 2006

REVISION HISTORY FIC8120 Programming Guide Date

Rev.

Changes Made



Oct. 2005



0.1





Jan.2006



0.2

z z z



Mar.2006



0.3

z z z z



June.2006



0.4

z z



Aug.2006



0.5

0.6

Update OTG chapter Update IDE chapter

z

Add I2C chapter

z



Added input OSD function Added color transform from RGB to YUV function RGB output through PCI interface Supported only D version chip

z

z

Aug.2006

Changed flash address define Added LCD and OSD IOCTL definitions Added MTD function

Add RTC chapter Add WDT chapter Update SD chapter Add 2.2.2.3 chapter Update 2.3.4 chapter

z z



Original

© Copyright Faraday Technology, 2006 All Rights Reserved. Printed in Taiwan 2006 Faraday and the Faraday Logo are trademarks of Faraday Technology Corporation in Taiwan and/or other countries. Other company, product and service names may be trademarks or service marks of others. All information contained in this document is subject to change without notice. The products described in this document are NOT intended for use in implantation or other life support application where malfunction may result in injury or death to persons. The information contained in this document does not affect or change Faraday's product specification or warranties. Nothing in this document shall operate as an express or implied license or indemnity under the intellectual property rights of Faraday or third parties. All information contained in this document was obtained in specific environments, and is presented as an illustration. The results obtained in other operating environments may vary. THE INFORMATION CONTAINED IN THIS DOCUMENT IS PROVIDED ON AN “AS IS” BASIS. In no event will Faraday be liable for damages arising directly or indirectly from any use of the information contained in this document. Faraday Technology Corporation No. 5, Li-Hsin Road III, Hsinchu Science Park, Hsinchu City, Taiwan 300, R.O.C. Faraday's home page can be found at: http://www.faraday-tech.com

TABLE OF CONTENTS

Chapter 1

Chapter 2

Chapter 3

Introduction .........................................................................................................................1 1.1 Version of the IP.......................................................................................................2 1.2 General Description..................................................................................................2 1.3 Requirements of Host Development Environment ....................................................2 1.4 Requirements of Common Platform Target System .................................................2 Linux Distribution Based on FA526 .....................................................................................5 2.1 Introduction...............................................................................................................6 2.1.1 FA526-Linux Distribution..............................................................................6 2.1.2 Install FA526-Linux Distribution ................................................................... 7 2.1.3 FA526-Linux Directory Structure .................................................................. 8 2.2 Building and Developing FA526-Linux......................................................................9 2.2.1 Kernel Tree .................................................................................................. 9 2.2.2 Building Kernel ............................................................................................ 9 2.2.3 Building ARMBOOT ................................................................................... 17 2.3 FA526-Linux OS Loader – ARMBOOT ...................................................................20 2.3.1 Running ARMBOOT .................................................................................. 20 2.3.2 ARMBOOT Environment Variables ............................................................ 20 2.3.3 ARMBOOT Command Reference.............................................................. 21 2.3.4 ARMBOOT Flash Support ......................................................................... 22 2.4 Booting FA526-Linux ..............................................................................................22 2.4.1 Boot FA526-Linux via FA-ICE .................................................................... 22 2.4.2 Booting FA526-Linux from ROM/Flash ...................................................... 22 2.4.3 Booting FA526-Linux by ARMBOOT .......................................................... 24 2.5 FA526-Linux Internals ............................................................................................26 2.5.1 I/O Address Mapping ................................................................................. 26 2.5.2 Processor .................................................................................................. 28 2.5.3 Timer ......................................................................................................... 31 2.5.4 Exception Handler ..................................................................................... 31 2.6 FA526-Linux Debugging.........................................................................................32 2.6.1 Debugging the Kernel ................................................................................ 32 Device Driver ....................................................................................................................34 3.1 I2S Audio Driver ......................................................................................................35 3.1.1 Introduction................................................................................................ 35 3.1.2 Audio Driver Guide .................................................................................... 35

FIC8120 Programming Guide www.faraday-tech.com i

3.2

3.3

3.4

3.5

3.6

3.7

3.8

3.1.3 Driver Internals .......................................................................................... 38 3.1.4 Reference .................................................................................................. 40 MAC Driver.............................................................................................................40 3.2.1 Introduction................................................................................................ 40 3.2.2 MAC Driver Guide...................................................................................... 42 3.2.3 Driver Internals .......................................................................................... 47 3.2.4 Reference .................................................................................................. 49 Serial Driver............................................................................................................49 3.3.1 Introduction................................................................................................ 49 3.3.2 Serial Driver Guide .................................................................................... 50 3.3.3 Driver Internals .......................................................................................... 53 3.3.4 Reference .................................................................................................. 56 SD Driver................................................................................................................56 3.4.1 Introduction................................................................................................ 56 3.4.2 SD/MMC Driver Guide ............................................................................... 57 3.4.3 Driver Internals .......................................................................................... 59 3.4.4 User Applications for SD/MMC Driver ........................................................ 62 3.4.5 Make module method ................................................................................ 62 3.4.6 Reference .................................................................................................. 62 LCD Driver..............................................................................................................63 3.5.2 LCD Driver Guide ...................................................................................... 64 3.5.3 Driver Internals .......................................................................................... 68 3.5.4 Reference .................................................................................................. 72 PCI Driver...............................................................................................................72 3.6.1 Introduction................................................................................................ 72 3.6.2 PCI Driver Guide........................................................................................ 72 3.6.3 Verifying by Realtek 8139d Chip PCI Network Card .................................. 74 3.6.4 Driver Internals .......................................................................................... 77 3.6.5 Reference .................................................................................................. 78 Capture Application ................................................................................................78 3.7.1 Introduction................................................................................................ 78 3.7.2 Configuration Setting ................................................................................. 79 3.7.3 Work Flow.................................................................................................. 80 3.7.4 Result ........................................................................................................ 80 3.7.5 Reference .................................................................................................. 81 TV Encoder Driver Application................................................................................81 3.8.1 Introduction................................................................................................ 81 3.8.2 Configuration Setting ................................................................................. 81 3.8.3 Work Flow.................................................................................................. 82

FIC8120 Programming Guide www.faraday-tech.com ii

3.9

3.10

3.11

3.12 3.13

3.14

3.15

3.16

3.17

3.18

3.19

Audio Two-Way Application....................................................................................83 3.9.1 Introduction................................................................................................ 83 3.9.2 Configuration Setting ................................................................................. 83 3.9.3 Work Flow.................................................................................................. 84 Audio Player Application.........................................................................................84 3.10.1 Introduction................................................................................................ 84 3.10.2 Configuration Setting ................................................................................. 85 3.10.3 Work Flow.................................................................................................. 85 IDE Driver Guide ....................................................................................................87 3.11.1 Introduction................................................................................................ 87 3.11.2 IDE Driver Guide........................................................................................ 88 3.11.3 Driver Internals .......................................................................................... 93 3.11.4 Reference .................................................................................................. 95 USB OTG Device Driver .........................................................................................95 Output OSD Play Application................................................................................112 3.13.1 Introduction.............................................................................................. 112 3.13.2 Configuration Setting ............................................................................... 113 3.13.3 Work Flow................................................................................................ 113 MTD Driver ...........................................................................................................115 3.14.1 Introduction.............................................................................................. 115 3.14.2 Configuration Setting ............................................................................... 115 3.14.3 Work Flow................................................................................................ 117 Input OSD Function ..............................................................................................117 3.15.1 Introduction.............................................................................................. 117 3.15.2 Configuration Setting ............................................................................... 118 Color transform Application ..................................................................................118 3.16.1 Introduction.............................................................................................. 118 3.16.2 Work Flow................................................................................................ 118 RTC Function .......................................................................................................119 3.17.1 Introduction.............................................................................................. 119 3.17.2 Configuration Setting ............................................................................... 120 3.17.3 Source code ............................................................................................ 121 WatchDog Function ..............................................................................................121 3.18.1 Introduction.............................................................................................. 121 3.18.2 Configuration Setting ............................................................................... 123 3.18.3 Source code ............................................................................................ 123 I2C Function .........................................................................................................124 3.19.1 Introduction.............................................................................................. 124 3.19.2 Source code ............................................................................................ 126

FIC8120 Programming Guide www.faraday-tech.com iii

3.19.3 Access I2C-bus function in kernel mode.................................................. 126 3.19.4 Access I2C function in user mode............................................................ 128 Appendix A: Hardware Assignment ..........................................................................................................131 A.1: FIC8120 Board I/O Address Mapping and Interrupt Assignment..............................131 Appendix B: Load Image to Target SDRAM .............................................................................................134 B.1: Load Image to Target SDRAM by AXD....................................................................134 B.2: Load Image to Target SDRAM by Ethernet..............................................................134 B.3: Load Image to Target SDRAM by UART .................................................................134 Appendix C: Programming Flash ..............................................................................................................135 Appendix D: bootpImage Flow..................................................................................................................137 Appendix E: ramdisk Maintenance ...........................................................................................................139 E.1: Create a New ramdisk .............................................................................................139 E.2: Add/Remove Files from ramdisk Image ...................................................................139

FIC8120 Programming Guide www.faraday-tech.com iv



Table 2-1. Table 2-2. Table 2-3. Table 2-4. Table 2-5. Table 2-6. Table 2-7. Table 2-8. Table 3-1. Table 3-2. Table 3-3. Table 3-4. Table 3-5. Table 3-6. Table 3-7. Table 3-8. Table 3-9. Table 3-10. Table 3-11. Table 3-12. Table 3-13. Table 3-14. Table 3-15. Table 3-16. Table 3-17. Table 3-18. Table 3-19. Table 3-20. Table 3-21. Table 3-22. Table 3-23. Table 3-24. Table 3-25. Table A-1.

LIST OF TABLES

Disk Space Requirements for Linux Host............................................................................6 FA526 Distribution Directories.............................................................................................8 Kernel Subdirectory Contents .............................................................................................9 Environment Variables ......................................................................................................21 ARMBOOT Commands.....................................................................................................21 FA526 Processor Related Functions.................................................................................29 Related Timer Source Files...............................................................................................31 Exception Handlers ...........................................................................................................32 I2S Source File List............................................................................................................35 DSP Device Number .........................................................................................................38 I2S Device Functions .........................................................................................................39 FMAC Source File List ......................................................................................................42 FMAC Driver Functions .....................................................................................................49 UART Clock ......................................................................................................................50 UART Source File List.......................................................................................................50 UART Device Number.......................................................................................................53 UART Driver Functions .....................................................................................................55 SD Source File List ...........................................................................................................57 SD Device Functions.........................................................................................................60 LCD Source File List .........................................................................................................64 LCD Driver Device Node ...................................................................................................68 LCD Driver Functions........................................................................................................69 PCI Source File List ..........................................................................................................72 PCI Driver Functions .........................................................................................................78 IDE Interrupt Number ........................................................................................................87 PCIDE I/O Memory ...........................................................................................................87 IDE Source File List ..........................................................................................................88 IDE Driver Device Node ....................................................................................................93 IDE Device Functions........................................................................................................94 Source Code Directory Structure ....................................................................................121 Source File List ...............................................................................................................121 Source Code Directory Structure ....................................................................................123 Source File List ...............................................................................................................123 Interrupt Number Assignment .........................................................................................131

FIC8120 Programming Guide www.faraday-tech.com v

Table A-2. Table C-1.

I/O Address Assignment..................................................................................................132 Command List .................................................................................................................135

FIC8120 Programming Guide www.faraday-tech.com vi



LIST OF FIGURES

1.

Figure 2-1. FA526 Distribution Directories...........................................................................8

2.

Figure 2-2. Linux Kernel Option Configuration Using GUI Display ....................................12

3.

Figure 2-3. Linux Kernel Option Configuration Using Menu Display..................................13

4.

Figure 2-4. File Content of mkbootp.sh .............................................................................15

5.

Figure 2-5. Configuring the Size of RAM Disk ...................................................................16

6.

Figure 2-6. File Content of faraday.h.................................................................................18

7.

Figure 2-7. Changing MAC & IP for ARMBOOT in config_cpe.h .......................................18

8.

Figure 2-8. Changing MAC for ARMBOOT in ftmac100.c .................................................18

9.

Figure 2-9. Flash/EEPROM Memory Mapping ..................................................................23

10.

Figure 2-10. tftp Setting.....................................................................................................24

11.

Figure 2-11. Environment Settings for ARMBOOT ............................................................25

12.

Figure 2-12. Downloading Linux Code from ARMBOOT ...................................................25

13.

Figure 2-13. Linux Message during Booting up .................................................................26

14.

Figure 2-14. I/O Address Mapping (FIC8120.c).................................................................27

15.

Figure 2-15. I/O Address Mapping (map.h) .......................................................................27

16.

Figure 2-16. IO_ADDRESS (FIC8120.h) ...........................................................................27

17.

Figure 2-17. Timer Function ..............................................................................................31

18.

Figure 3-1. Kernel Configuration – Sound .........................................................................36

19.

Figure 3-2. Kernel Configuration – OSS Sound Modules ..................................................37

20.

Figure 3-3. Loading I2S Audio Driver.................................................................................37

21.

Figure 3-4. Audio Driver Architecture ................................................................................39

22.

Figure 3-5. Kernel Configuration – General Setup ............................................................43

23.

Figure 3-6. Kernel Configuration – General Setup -> Networking Support ........................43

24.

Figure 3-7. Kernel Configuration – General Setup -> Networking Support (1)...................44

25.

Figure 3-8. Kernel Configuration – General Setup -> Networking Support (2)...................44

26.

Figure 3-9. Kernel Configuration for Faraday FTMAC100 Support....................................45

27.

Figure 3-10. Linux Booting Message – MAC .....................................................................46

28.

Figure 3-11. Use of Network Device – ifconfig, ping..........................................................46

29.

Figure 3-12. FMAC Driver Architecture .............................................................................47

30.

Figure 3-13. Kernel Configuration – System Type.............................................................51

31.

Figure 3-14. Kernel Configuration – UART Clock ..............................................................51

32.

Figure 3-15. Kernel Configuration – Character Devices ....................................................52

FIC8120 Programming Guide www.faraday-tech.com vii

33.

Figure 3-16. Kernel Configuration – CPE Serial Port Support ...........................................52

34.

Figure 3-17. Linux Booting Message – Serial....................................................................53

35.

Figure 3-18. UART Driver Architecture..............................................................................55

36.

Figure 3-19. Kernel Configuration – File Systems .............................................................58

37.

Figure 3-20. Kernel Configuration – MSDOS File Systems ...............................................58

38.

Figure 3-21. SD Driver Auto-Load Script...........................................................................59

39.

Figure 3-22. SD/MMC Driver Architecture .........................................................................60

40.

Figure 3-23. Kernel Configuration – Character Devices ....................................................64

41.

Figure 3-24. Kernel Configuration – Enable Virtual Terminal.............................................65

42.

Figure 3-25. Kernel Configuration – Console Drivers ........................................................65

43.

Figure 3-26. Kernel Configuration – Enable Faraday FTLCDC100 LCD Controller and set output format ................................................................................................................................66

44.

Figure 3-27. Kernel Configuration – Set LCD panel module..............................................67

45.

Figure 3-28. Kernel Configuration – Enable 16 bpp Packed Pixels Support......................67

46.

Figure 3-29. LCD Driver Architecture. ...............................................................................68

47.

Figure 3-30. Kernel Configuration – General Setup ..........................................................73

48.

Figure 3-31. Kernel Configuration – Enable PCI Support ..................................................73

49.

Figure 3-32. Kernel Configuration – Network Device Support ...........................................74

50.

Figure 3-33. Kernel Configuration – Ethernet (10 or 100 Mbit) ..........................................74

51.

Figure 3-34. Kernel Configuration – RealTek PCI Card.....................................................75

52.

Figure 3-35. Ethernet Card Initialize Status.......................................................................76

53.

Figure 3-36. Verifying Connection of Ethernet by Ping......................................................76

54.

Figure 3-37. PCI Driver Architecture .................................................................................77

55.

Figure 3-38. Kernel Configuration for Capture Program ....................................................79

56.

Figure 3-39. Kernel Configuration for TV Encoder Program ..............................................81

57.

Figure 3-40. Kernel Configuration for TV Encoder Program (1).........................................82

58.

Figure 3-41. Kernel Configuration for Audio Driver............................................................83

59.

Figure 3-42. Kernel Configuration for Audio Driver............................................................85

60.

Figure 3-43. Kernel Configuration – ATA/ATAPI/MFM/RLL Support .................................88

61.

Figure 3-44. Kernel Configuration – IDE, ATA and ATAPI Block Devices .........................89

62.

Figure 3-45. Kernel Configuration – Include IDE/ATA-2 DISK Support .............................89

63.

Figure 3-46. Kernel Configuration – Faraday FTIDE020_S Support (PIO Mode) ..............90

64.

Figure 3-47. Kernel Configuration – Faraday FTIDE020_S Support (DMA Mode) ............90

65.

Figure 3-48. Linux Booting Message – IDE Driver with PIO Mode ....................................91

66.

Figure 3-49. Linux Booting Message – IDE Driver with DMA Mode ..................................92

67.

Figure 3-50. IDE Driver Architecture .................................................................................94

68.

Figure 3-51. Kernel Configuration for GPIO Driver ..........................................................113

69.

Figure 3-52. Kernel Configuration for MTD Driver ...........................................................115

FIC8120 Programming Guide www.faraday-tech.com viii

70.

Figure 3-53. Kernel Configuration for MTD Memory Driver .............................................116

71.

Figure 3-54. Kernel Configuration for MTD Mapping Driver ............................................116

72.

Figure 3-55. Kernel Configuration for MTD JFFS2 File System.......................................117

73.

Figure 3-56. Kernel Configuration for Input OSD Driver ..................................................118

74.

Figure 3-57. Kernel Configuration for RTC Driver ...........................................................120

75.

Figure 3-58. Kernel Configuration for RTC Driver ...........................................................123

76.

Figure C-1. Physical Memory ..........................................................................................135

77.

Figure D-1. Bus 16 bit width bootpImage Components ...................................................137

78.

Figure D-2. Bootp Procedure ..........................................................................................137

FIC8120 Programming Guide www.faraday-tech.com ix

Chapter 1 Introduction This chapter contains the following sections: •

1.1

Introduction



1.2

General Description



1.3

Requirements of Host Development Environment



1.4

Requirements of Common Platform Target System

FIC8120 Programming Guide www.faraday-tech.com 1

1.1 Version of the IP This is the preliminary version of the IP.

1.2 General Description Faraday’s MDC1 FIC8120 hardware environment is a highly efficient RISC-based platform for the purpose of verifying and evaluating AMBA-based designs in the early development stage. The complete set of MDC1 FIC8120 platform consists of a main board (MB120) equipped with FIC8120 (FFA0AA016AA) chip and an embedded Faraday FA526 CPU. This document contains the Linux programming guide for Faraday MDC1 FIC8120 platform. Please refer to FFA0AA016AA/FWAA198AA/MB120 documents for additional information. There are two Linux versions involved in programming, the Linux, and the uClinux. The uClinux is a Linux version without the Memory Management Unit (MMU). Faraday RISC FA526 is MMU-based CPU, while FA510 is not. Both FA526 and Faraday’s peripheral IP drivers have been ported to Linux. Chapter 1 of this document contains the Linux user guide and the programming guide for peripheral IP drivers. Chapter 2 introduces Linux distribution based on FA526. Chapter 3 introduces the programming guide of device drivers. In Chapter 3, this document explains only the most basic device drivers; for further information on USB device, Watchdog Timer, Real Time Clock, security engine, USB Host, and other latest drivers, please refer to individual documents.

1.3 Requirements of Host Development Environment The required development environment of the host system developing Linux is listed as follows: Hardware: •

Intel x86 compatible PC



Standard 16550 UART

Software: •

Standard Linux distribution (RedHat 7.3 ~ 8.0 or above)



FA526-based Linux distribution

1.4 Requirements of Common Platform Target System

FIC8120 Programming Guide www.faraday-tech.com 2

The requirements of the target system developing Linux kernel and device drivers are listed as follows: •

Faraday MDC1 FIC8120 ○

MB120 (including FIC8120)



64 MB SDRAM on board



32 MB Flash on board

FIC8120 Programming Guide www.faraday-tech.com 3

Chapter 2 Linux Distribution Based on FA526 This chapter contains the following sections: •

2.1

Introduction



2.2

Building and Developing FA526-Linux



2.3

FA526-Linux OS Loader – ARMBOOT



2.4

Booting FA526-Linux



2.5

FA526-Linux Internals



2.6

FA526-Linux Debugging

FIC8120 Programming Guide www.faraday-tech.com 5

2.1 Introduction This chapter introduces FA526-based Linux architecture and implementations to help you understand and install FA526-based Linux easily and quickly. The FA526-Linux implements a Linux-2.4.19 software development environment for Faraday FA526 processor and peripheral IPs. With the information provided in this chapter, you can quickly install FA526-Linux on Faraday MDC1 FIC8120 platform to implement your applications. The following sections describe the system requirements as well as how to install FA526-Linux distribution.

2.1.1

FA526-Linux Distribution

The FA526-Linux distribution is a tar archive. The following is an example of how file name looks like: arm-linux-20051230.tgz The file name is a combination of “arm-linux-” and the released date, say “20051230”, which indicates that this file is released on December 30, 2005. Please refer to the following table for details.

Table 2-1.

Disk Space Requirements for Linux Host

Source Item

Disk Size



GCC Toolchain



240 MB



Linux Kernel



371 MB



User Application



97 MB



Ramdisk Sample



6 MB



Total



714 MB

FIC8120 Programming Guide www.faraday-tech.com 6

2.1.2

Install FA526-Linux Distribution

The installation of FA526-Linux can be achieved by tar-archive extraction with the sequence stated below: •

Copy the file “arm-linux-20051230.tgz” to /usr/src directory # cp arm-linux-20051230.tgz /usr/src



Extract the file “arm-linux-20051230.tgz” # cd /usr/src # tar zxvf arm-linux-20051230.tgz



Install toolchain (GCC-2.95.3, Binutils-2.11.2, and GLIBC-2.2.3) to directory /usr/local # cp /usr/src/arm-linux/toolchain/arm-linux-toolchain.tgz /usr/local # cd /usr/local # tar zxvf arm-linux-toolchain.tgz # rm -f arm-linux-toolchain.tgz This step will extract the output files “GCC-2.95.3”, “Binutils-2.11.2”, and “GLIBC-2.2.3” and stored in the directory /usr/local/arm.



Add GCC execution path to shell environment You can add the working path to your environment with the following command. # export PATH=$PATH:/usr/local/arm/2.95.3/bin For your convenience, you can edit the .bashrc file to add a line under BASH environment in your home directory. PATH=$PATH:/usr/local/arm/2.95.3/bin

After completing the installation steps, you can then build the FA526-Linux kernel or application.

FIC8120 Programming Guide www.faraday-tech.com 7

2.1.3

FA526-Linux Directory Structure

Let us assume the top directory is /usr/src/arm-linux/. When you extract the tar archive like “arm-linux-20051230.tgz” on /usr/src/arm-linux/, it builds a set of subdirectories as shown in Figure 2-1.

/usr/src

Arm-linux

toolchain/ arm-linux-2.4.19/ user/

busybox-0.60.1 Customize Application

images/

ramdisk.gz Customize Ramdisk

1.

Figure 2-1.

FA526 Distribution Directories

格式化: 不要貼齊格線

Table 2-2 lists the source directories and explains what type of files located in it. For example, the user

刪除: Table 2-2

application is located in /usr/src/arm-linux/user/ directory, while customized ramdisk is put in

格式化: 不使用拼字或文 法檢查, 不要貼齊格線

/usr/src/arm-linux/images/ directory.

格式化: 不要貼齊格線

Table 2-2.

FA526 Distribution Directories

Directory

Description



toolchain/



Directory for the repository of arm-Linux tool-chain.



arm-linux-2.4.19/



Directory for the repository of Linux kernel source.



user/



Directory for the repository of user application.



images/



Directory for the repository of ramdisk images.



ARMBOOT1.1.0/



Directory for arm boot.

FIC8120 Programming Guide www.faraday-tech.com 8

2.2 Building and Developing FA526-Linux This section explains how you can configure and build an FA526-Linux kernel for embedded system.

2.2.1

Kernel Tree

The FA52x Linux kernel is located in the following directory: /usr/src/arm-linux/arm-linux-2.4.19/ The structure of the FA526-Linux subdirectory is identical to that of standard Linux kernel version 2.4.19. The following table shows the contents of the Linux kernel subdirectory. For the purpose of brevity, the stands for the directory /usr/src/arm-linux/arm-linux-2.4.19.

Table 2-3.

Kernel Subdirectory Contents

Kernel Subdirectory

Contents



/arch/arm



Architecture-dependent code for ARM processors



/Documentation



Documentations for Linux kernel



/drivers



Device drivers, divided into various subdirectories



/fs



Various file systems supported by Linux kernel



/include



Kernel head files



/init



Kernel startup functions



/ipc



Sources of System V IPC



/kernel



Kernel core sources



/lib



Standard C library sources



/mm



Kernel memory management



/net



Implementation of various network protocols

2.2.2

Building Kernel

This section tells you how to build the kernel image for FA526 architecture.

2.2.2.1

Configuring the Kernel

The first step to build Linux kernel is to configure kernel. The configuration file is located at

FIC8120 Programming Guide www.faraday-tech.com 9

/.config for standard Linux.

FIC8120 Programming Guide www.faraday-tech.com 10

In general, you may want to reconfigure FA526-Linux for one or more reasons stated below: •

Customized processor and board functionality: Modify UART clock, system clock, etc.



Customized hardware devices: Add or remove particular devices.



Customized kernel functionality: Add or remove a kernel feature such like network support.

There are two ways provided for Linux kernel to configure options mentioned above: •

Change to directory

1. Use menu display to select options for configuration: # make menuconfig

2. Use GUI display to select options for configuration: # make xconfig Using GUI display to configure Linux kernel options is shown in Figure 2-2.

FIC8120 Programming Guide www.faraday-tech.com 11

2.

Figure 2-2.

Linux Kernel Option Configuration Using GUI Display

Using menu display to select configuration options of Linux kernel is shown in Figure 2-3.

FIC8120 Programming Guide www.faraday-tech.com 12

3.

Figure 2-3.

Linux Kernel Option Configuration Using Menu Display

FIC8120 Programming Guide www.faraday-tech.com 13

The main options of FA526 system are as follows: (CPE) ARM system type Select CPE board to support Faraday CPE. [*] Support FA526 processor Set FA526 series processor option to support FA526 CPU. (FIC8120) Platform environment Choose setting from the following platforms: A320: Faraday SoCreative! platform FIC8120: Faraday MDC1 FIC8120 platform FIE7000: Faraday FIE7000 platform Please refer to A320/FIC8120/FIE7000 user guide for detailed information. (110592000) System clock The default system clock is 110 MHz for MDC1 FIC8120 platform. You must modify this clock based on actual board setting. Please refer to A320/FIC8120/FIE7000 platform specification for more information. (22118400) UART clock The UART clock is 22.1184 MHz for MDC1 FIC8120 platform while the default UART clock is 22.1184 MHz for FIC8120 platform. Please set UART clock based on actual board setting. [ ] Disable I-Cache [ ] Disable D-Cache You can disable I-Cache and/or D-Cache by setting above configurations. [ ] Disable Write Buffer You can disable the cache write buffer by setting this configuration. [ ] Force write through D-Cache You can force FA526 cache to enter write-through mode. The default is write-back mode. [ ] Idle mode support You can use this configuration to enable CPU idle mode. [ ] BTB support You can use this configuration to enable branch target buffer (BTB). Please refer to FA526 Data Sheet for detailed CPU functions.

FIC8120 Programming Guide www.faraday-tech.com 14

2.2.2.2

Making the Kernel

If this is the first time for you to make Linux kernel, you may clean all object files and re-create the dependency. If you modify the kernel configuration, you should also invoke “make dep” command. An example is listed as follows: # make clean # make dep FA526-Linux provides the shell-script “mkbootp.sh” for you to easily make the kernel. # ./mkbootp.sh It creates the final kernel image named bootpImage and kernel ELF file named vmlinux. You may modify mkbootp.sh for one or more reasons stated below: •

Use customized ramdisk: Modify command “make bootpImage INITRD=” to specify the name of your ramdisk. Please modify command “Default RAM disk size” to set your ramdisk size (refer to Figure 2-5). You can configure it with “make xconfig” command located at “Block devices”.



Copy output image to specified directory: Modify the command “cp <source> ” in the mkbootp.sh file to suit your requirement.

格式化: 緊縮 0.3 pt 刪除: Figure 2-5 格式化: 不使用拼字或文 法檢查, 緊縮 0.3 pt 格式化: 緊縮 0.3 pt

4.

Figure 2-4.

File Content of mkbootp.sh

FIC8120 Programming Guide www.faraday-tech.com 15

5.

Figure 2-5.

Configuring the Size of RAM Disk

You can select either dynamic or static mode. When the dynamic mode is selected, ramdisk will link to kernel image. When the static mode is selected, you can manipulate ramdisk start address and end address by yourself, and therefore you must write ramdisk to these addresses manually.

FIC8120 Programming Guide www.faraday-tech.com 16

2.2.2.3

Making IPCAM or IPTV Kernel

If your EVB is Faraday IPCAM, you must “cp IPCAM.config .config” , then run “make menuconfig” , don’t need change any setting and then save again, run “make clean;make dep;./mkipcam.sh” , ramdisk name is “IPCAM_V1_ramdisk.gz”and then we can get Linux image. If your EVB is Faraday IPTV, you must “cp IPTV.config .config” , then run “make menuconfig” , don’t need change any setting and then save again, run “make clean;make dep;./mkipcam.sh” , ramdisk name is “IPCAM_V1_ramdisk.gz”and then we can get Linux image.

2.2.3

Building ARMBOOT

FA526-Linux uses ARMBOOT as the OS loader.

2.2.3.1

Configuring ARMBOOT

The FA526 ARMBOOT maintains the configuration file, faraday.h, to configure different hardware environments. This file is located at /usr/src/arm-linux/armboot-1.1.0/faraday.h. You may want to modify faraday.h for one or more reasons stated below, but in most case, you do not have to change its values: •

Modify system clock. The default system clock is 44 MHz for MDC1 FIC8120 Platform.



Modify UART clock. The UART clock is 22.1184 MHz for MDC1 FIC8120 Platform.



Modify flash bank number. The flash bank number is 1 for MDC1 FIC8120 Platform.

FIC8120 Programming Guide www.faraday-tech.com 17

#define SYSTEM_CLOCK 44000000 //44 MHz #define UART_CLOCK 22118400 //22.1184 MHz ASIC version #define CONFIG_FLASH_BANK 1 //bank 0,1,2,3,4,5,6,7

6.

Figure 2-6.

File Content of faraday.h

In addition to this, you may want to change MAC address to download Linux code to MediaCreative platform. To this end, you must modify the definition - CONFIG_ETHADDR in armboot-1.1.0/include/configs/config_cpe.h as shown in Figure 2-7, and the variable ftmac100_mac_addr in armboot-1.1.0/drivers/ftmac100.c as shown is Figure 2-8.

#define CONFIG_ETHADDR #define CONFIG_NETMASK #define CONFIG_IPADDR #define CONFIG_SERVERIP 7.

Figure 2-7.

00:40:25:00:00:01 255.255.255.0 192.168.131.123 192.168.131.122

Changing MAC & IP for ARMBOOT in config_cpe.h

static char ftmac100_mac_addr[] = {0x00, 0x40, 0x25, 0x00, 0x00, 0x01}; //MAC 8.

2.2.3.2

Figure 2-8.

Changing MAC for ARMBOOT in ftmac100.c

Making ARMBOOT

Once you have modified MAC and IP, you can build ARMBOOT with the following commands: # cd /usr/src/arm-linux/armboot-1.1.0 # make It creates the file “armboot.bin” under the folder as shown in the first line. You should follow the instruction to burn ARMBOOT into FIC8120’s flash, and write the specific image armboot.bin to the flash address 0x80600000, with reference to the flash programming procedure provided in Appendix C.

FIC8120 Programming Guide www.faraday-tech.com 18

FIC8120 Programming Guide www.faraday-tech.com 19

2.3 FA526-Linux OS Loader – ARMBOOT ARMBOOT is the famous OS loader in the Linux world. It is capable of loading image from terminal protocol like kermit and booting Linux kernel. It also provides flash utilities and Ethernet TFTP transfer functions.

2.3.1

Running ARMBOOT

FA526-Linux Distribution provides ARMBOOT code to do the following tasks: •

Flash programming



Data transfer from PC to target by UART (kermit) or Ethernet (TFTP)



Load or branch Linux kernel

You can run the ARMBOOT code from flash or via ICE.

2.3.1.1

Running ARMBOOT from Flash

If the boot code (rominit.bin) and the ARMBOOT code are ready in EEPROM and flash, you can run ARMBOOT from flash by keystroke ESC at the reset time. Please refer to Appendix E for information about the CPE boot flow.

2.3.1.2

Running ARMBOOT via ICE

You may run ARMBOOT via ICE, by following this procedure:

2.3.2



Connect FA526 target and your PC with JTAG ICE



Open AXD debugger, and load armboot.bin to the memory address 0x0



Set PC to 0x0, and run

ARMBOOT Environment Variables

ARMBOOT maintains a number of environment variables for various functions. You can display them by the following command. CPE> printenv

FIC8120 Programming Guide www.faraday-tech.com 20

You can set the environment value by the command “setenv name value” where “name” is the environment variable name and “value” is the value you want to set. The following command is an example to set IP address environment. CPE> setenv ipaddr 192.168.52.48 Table 2-4 shows the environment variables used in this document.

Table 2-4.

Environment Variables

Environment Variable

Description



Ipaddr



The target IP address



Serverip



TFTP server IP address



Ethaddr



MAC address value



Netmask



IP address netmask value

2.3.3

ARMBOOT Command Reference

The most commonly used commands in ARMBOOT are listed in Table 2-5. You can type “help” on the ARMBOOT terminal to display the command list.

Table 2-5.

ARMBOOT Commands

Command

Description



printenv



Print the environment variables of ARMBOOT.



setenv [env] [value]



Set environment variable.



go [address]



Jump to specific address.



flinfo



Print the flash information.



erase [address 1] [address 2]



Erase flash from address 1 to address 2.



cp.b [source] [destination] [size]



Program flash from source to destination.



loadb [address]



Load binary to specific address by Kermit protocol.



tftp [address] [image]



TFTP transfer of images to specific address.

FIC8120 Programming Guide www.faraday-tech.com 21

2.3.4

ARMBOOT Flash Support

If you use ROM boot, you must define ROM init, if you use flash boot, you must define flash boot at config_cpe.h file. //#define PHYS_FLASH_1 #define PHYS_FLASH_1

0x80000000 /* Flash boot */ 0x80400000 /* ROM boot */

Note: This armboot only support 16 bit flash, if you don’t use Faraday suggest flash type, you must check if this program detect your flash type is ok.This program will show “yes” message such as : Check for MX29LV008B flash(8bit x4) DDI1=0x180089, DDI2=0xff0000 (no) Check for MX29LV640BB flash(16bit x1) DDI1=0x89, DDI2=0x18 (no) Check for MX29LV640BT flash(16bit x1) DDI1=0x89, DDI2=0x18 (no) Check for SST39VF080 flash(8bit x4) DDI1=0x180089, DDI2=0xff0000 (no) Check for SST39VF016 flash(8bit x4) DDI1=0x180089, DDI2=0xff0000 (no) Check for SST36VF1601 flash(16bit x1) DDI1=0x89, DDI2=0x18 (no) Check for SST36VF3201 flash(16bit x1) DDI1=0x89, DDI2=0x18 (no) Check for Intel flash(16bit x2) DDI1=0x180089, DDI2=0xff0000 (no) Check for Intel flash(16bit x1) DDI1=0x89, DDI2=0x18 (yes)

2.4 Booting FA526-Linux FA526-Linux can be booted on the target system using either of the following two boot scenarios: •

Boot FA526-Linux via FA-ICE



Boot FA526-Linux from ROM/Flash

2.4.1

Boot FA526-Linux via FA-ICE

You can load FA526-Linux kernel image to a specific address via FA-ICE and jump there. The procedure is as follows: •

Load bootpImage to the address 0x2000000 (recommended) by AXD debugger. (Please refer to Appendix B for the procedure.)



2.4.2

Set PC to 0x2000000 on AXD debugger and run it.

Booting FA526-Linux from ROM/Flash

You may wish to self-boot the Linux kernel from ROM/Flash automatically. To do this, specified boot code and ARMBOOT code are required. The following procedure describes the way to boot FA526-Linux from

FIC8120 Programming Guide www.faraday-tech.com 22

ROM/Flash automatically (case of 8-bit bus width). •

Prepare ROM code: Write the specific image rominit.bin to EEPROM.



Prepare ARMBOOT code: Write the specific image armboot.bin to the flash address 0x80600000.



You can refer to Appendix C for the flash programming procedure.

Prepare Linux kernel image: Write the specific image mbootpImage to the flash address 0x80640000.



You can refer to Appendix C for the flash programming procedure.

Flash Address Map

• •

ROM boot 0x80400000



0x80500000

Configure MTD

0x80100000



0x80600000

ARMBOOT

0x80200000



0x80640000

bootpImage

0x80240000

9.

Figure 2-9.

Burn-In Code

Flash boot 0x80000000

EEPROM Address Map

0x0

Burn-In Code

Flash/EEPROM Memory Mapping

FIC8120 Programming Guide www.faraday-tech.com 23

2.4.3

Booting FA526-Linux by ARMBOOT

In most parts of the development stage, you need to do iteration to modify code and/or download code until you are satisfied with the result; under such condition, you need ARMBOOT to download and run code. The required procedure is as follows: •

10.

Set up tftp server on your Linux host, and set /etc/xinetd.d/tftp as shown in Figure 2-10.

Figure 2-10.



tftp Setting

Use the Linux making shell (mkbootp.sh) within this package to compile code and generate Linux code and put into the folder /tftpboot. To run Linux code, take the following steps: 1.

Reset FIC8120 target

2.

Select item “90) GO ARMBOOT”

3.

Make sure IP addresses of Linux-Host and FIC8120 are correct, (printenv), as shown in Figure 2-11.

4.

Key in the command “tftp 0x2000000 mbootpImage” to download code as shown in Figure 2-12.

5.

Boot up Linux by the command “go 0x2000000”. You can see Linux boot-up message on the screen as shown in Figure 2-13.

FIC8120 Programming Guide www.faraday-tech.com 24

11.

Figure 2-11.

Environment Settings for ARMBOOT

12.

Figure 2-12.

Downloading Linux Code from ARMBOOT

FIC8120 Programming Guide www.faraday-tech.com 25

13.

Figure 2-13.

Linux Message during Booting up

2.5 FA526-Linux Internals This section briefly describes the implementation of FA526-Linux.

2.5.1

I/O Address Mapping

Since FA526-Linux uses MMU-based Linux kernel, it needs I/O memory mapping to access I/O peripheral. The I/O address mapping on the FA526-Linux is defined in “/arch/arm/mach-cpe/FIC8120.c” as shown in Figure 2-14. You can refer to the data structure of map_desc in “/include/asm-arm/mach/map.h” as shown in Figure 2-15. The most important item on map_desc is “virtual I/O address” and “physical I/O address” pair. Figure 2-14

FIC8120 Programming Guide www.faraday-tech.com 26

shows an example of mapping virtual I/O address IO_ADDRESS (CPE_UART1_BASE) to physical I/O address CPE_UART1_BASE for Faraday UART. The IO_ADDRESS() is defined in “/include/asm/arch/cpe/FIC8120.h” as shown in Figure 2-16. static struct map_desc cpe_io_desc[] __initdata = { { IO_ADDRESS(CPE_PWM_BASE), CPE_PWM_BASE, SZ_4K, { IO_ADDRESS(CPE_UART1_BASE), CPE_UART1_BASE, SZ_4K, { IO_ADDRESS(CPE_UART2_BASE), CPE_UART2_BASE, SZ_4K, { IO_ADDRESS(CPE_CT_BASE), CPE_CT_BASE, SZ_4K, { IO_ADDRESS(CPE_IC_BASE), CPE_IC_BASE, SZ_4K, … };

14.

Figure 2-14.

DOMAIN_IO, DOMAIN_IO, DOMAIN_IO, DOMAIN_IO, DOMAIN_IO,

0, 0, 0, 0, 0,

1}, 1}, 1}, 1}, 1},

I/O Address Mapping (FIC8120.c)

struct map_desc { unsigned long virtual; unsigned long physical; unsigned long length; int domain:4, prot_read:1, prot_write:1, cacheable:1, bufferable:1, last:1; };

15.

Figure 2-15.

I/O Address Mapping (map.h)

#define IO_BASE 0xF0000000 // VA of IO #define IO_ADDRESS(x) (((x >> 4)&0xffff0000) + (x & 0xffff) + IO_BASE)

16.

Figure 2-16.

IO_ADDRESS (FIC8120.h)

You may modify FIC8120.c and FIC8120.h when: •

Any peripheral device is added or removed



Device’s physical I/O address or size is changed

FIC8120 Programming Guide www.faraday-tech.com 27

2.5.2

Processor

FA526 processor related functions are defined in “/arch/arm/mm/proc-fa526.S”. Table 2-6 is a list of the processor related functions.

FIC8120 Programming Guide www.faraday-tech.com 28

Table 2-6.

FA526 Processor Related Functions

Category

Function Name

Description





cpu_fa526_data_abort

• This function is used to obtain data abort information from coprocessor.



cpu_fa526_check_bugs

• This function is where host-specific code can check for known processor errata and implementation workarounds.



cpu_fa526_proc_init

• This function performs processor initialization, if needed.



cpu_fa526_proc_fin

• This function is called when machine restarts. It cleans and disables cache and turns off interrupts.



cpu_fa526_reset

• This function performs system soft reset and branch to reset vector.



cpu_fa526_do_idle

• This function implements the CPU idle function to reduce power consumption.



• E





MISC

CACHE

D-CACH

I-CACHE

TLB

• Page Table

• cpu_fa526_cache_clean_invalidat e_all



• cpu_fa526_cache_clean_invalidat e_range

• This function cleans and invalidates all cache lines associated with the related area of memory.



cpu_fa526_flush_ram_page

• This function cleans and invalidates all cache lines associated with the related area of memory.

• ge

cpu_fa526_dcache_invalidate_ran

• This function throws away all D-cached data in the specified region without an obligation to write them back.



cpu_fa526_dcache_clean_range

• This function cleans all D-cached data in the specified region and writes the page out to disk.



cpu_fa526_dcache_clean_page

• This function cleans a single page of D-cache so that any future aliased mappings will be consistent at the time they are created.



cpu_fa526_dcache_clean_entry

• This function cleans the specified entry of any caches so that the MMU translation fetches will obtain correct data.

• e

cpu_fa526_icache_invalidate_rang

• This function invalidates a range of virtual addresses from the I-Cache.

• e

cpu_fa526_icache_invalidate_pag

• This function invalidates a page of virtual addresses from the I-Cache.



cpu_fa526_tlb_invalidate_all





cpu_fa526_tlb_invalidate_range

• This function invalidates TLB entries covering the specified range.



cpu_fa526_tlb_invalidate_page

• This function invalidates TLB entries covering the specified page.



cpu_fa526_set_pgd

• This function sets the translation base pointer as described by pgd.

This function cleans and invalidates all cache lines.

This function invalidates all TLBs.

FIC8120 Programming Guide www.faraday-tech.com 29

Category

Function Name

Description



cpu_fa526_set_pmd



This function sets a level-1 translation table entry.



cpu_fa526_set_pte



This function sets a level-2 page table entry.

FIC8120 Programming Guide www.faraday-tech.com 30

2.5.3

Timer

For Faraday FIC8120, all timer interrupts are IRQ. However, to ensure compatibility, you must use timer 2 in FIC8120. The related timer source files are listed in Table 2-7 below:

Table 2-7.

Related Timer Source Files

File •

Description /arch/arm/kernel/time.c



Provides timer_init() function called by kernel boot-up procedure.

/arch/arm/mach-cpe/cpe_tim e.c



Implements low-level timer functions.





Provides setup_timer() function and interrupt service routine.

/include/asm/arm/time.h

The layer relationship is demonstrated in Figure 2-17. Linux kernel boot-up procedure (main.c) calls timer_init() to initialize timer function. Then setup_timer() is called to set up timer function and install interrupt service routine. “cpe_time.c” provides low-level timer function to control the timer device.

main.c timer.init0 time.c

setup-timer0

time.h

fLib_Timer_xxx() cpe_time.c

17.

2.5.4

Figure 2-17.

Timer Function

Exception Handler

The FA526-Linux exception handler is implemented in the file “/arch/arm/kernel/entry-armv.S”. Table 2-8 is a list of the exception handlers. For example, when IRQ occurs in USER mode, exception handler “__irq_usr” is called. Note that “__irq_invalid” is the exception handler for invalid situations such as occurrence of IRQ under FIQ mode.

FIC8120 Programming Guide www.faraday-tech.com 31

Table 2-8.

Exception Handlers USER Mode

FIQ Mode

IRQ Mode

SVC Mode

ABT Mode

UNDEF Mode



IRQ

• r

__irq_us

• __irq_in valid

• __irq_in valid

• c

__irq_sv

• __irq_in valid

• lid

__irq_inva



FIQ

• r

__fiq_us

• __fiq_in valid



• c

__fiq_sv

• c



__fiq_svc

__fiq_irq

__fiq_sv

• Data Abort

• __dabt_ usr

• __dabt_in valid

• __dabt_in valid

• __dabt_ svc

• __dabt_in valid

• __dabt_in valid

• Prefetch Abort

• __pabt_ usr

• __pabt_in valid

• __pabt_in valid

• __pabt_ svc

• __pabt_in valid

• __pabt_in valid

• Undefine d Inst.

• sr

• __und_i nvalid

• __und_i nvalid

• vc

• __und_i nvalid

• __und_inv alid

__und_u

__und_s

2.6 FA526-Linux Debugging FA526-Linux Distribution provides you with information on how to debug Linux kernel code and user application programs.

2.6.1

Debugging the Kernel

AXD is used to debug Linux kernel on development host by FA-ICE (JTAG interface). AXD supports ELF Dwarf-2 debug format that can also be generated by GCC compiler. The additional action you have to take for debugging is to enable the “Include debugging information in kernel binary” option (make xconfig -> General Setup -> kernel support for ELF binaries) on the kernel configuration. The detailed debugging procedure is as follows: •

Load bootpImage to SDRAM 0x2000000. (Please refer to Appendix B for the procedure.)



Set PC to 0x2000000 on AXD debugger. Clear the “Vector catch” and “Semihosting” options on AXD debugger.



Run a few seconds, and stop AXD from running. (This is for setting breakpoint at 0x8054. You have to run it until kernel has been decompressed to 0x8000. The best point to stop AXD from running is the string “Uncompressing Linux…” appearing on the terminal.)



Set breakpoint to 0x8054 on AXD debugger and run it.



After stopping AXD debugger and catching breakpoint 0x8054, you can use “Step in” on AXD debugger until reaching the address 0xc0008080.

FIC8120 Programming Guide www.faraday-tech.com 32



Launch “Load debug symbols” on AXD to load vmlinux image.



You can debug Linux kernel now.

Note that the source level debugging supports C code only. Assembly code is not supported.

FIC8120 Programming Guide www.faraday-tech.com 33

Chapter 3 Device Driver This chapter serves as a guide to device driver programming for each component. This chapter contains the following sections: •

3.1

I2S Audio Driver



3.2

MAC Driver



3.3

Serial Driver



3.4

SD Driver

刪除: I2S/AC97 Audio Driver

FIC8120 Programming Guide www.faraday-tech.com 34

3.1 I2S Audio Driver 3.1.1

Introduction

Described below is the implementation of Faraday I2S audio driver on Linux operating system.

3.1.1.1

Audio I/O Resource Overview

Faraday’s I2S audio I/O resource and memory are briefly listed in Appendix A. You may refer to the FIC8120 hardware specification for the detailed audio clock setting.

3.1.1.2

Source File Overview

FA526-Linux provides the audio driver to implement the Open Sound System (OSS) driver. The related files on Linux are shown in Table 3-1. Please note that is the top path of the kernel source tree.

Table 3-1.

I2S Source File List

File

Description



/ drivers/sound/fac97.c



Faraday audio driver for AC97



/ drivers/sound/fi2s.c



Faraday A320 platform audio driver for I2S



/ drivers/sound/fi2s_fie7000.c



Faraday FIE7000 platform audio driver for I2S



/ drivers/sound/fi2s_fie8100.c

• Faraday FIE8100, FIC8120 platform audio driver 2 for I S



/ drivers/sound/wm8731.c



wm8731 audio codec driver



/ drivers/sound/msp4458g.c



msp4458g audio codec driver

3.1.2

Audio Driver Guide

To activate Faraday I2S audio function, you have to select some options in the kernel configuration menu – “Sound” and “OSS sound modules”. Figure 3-1 and Figure 3-2 show the options that need to be selected for the audio driver.

FIC8120 Programming Guide www.faraday-tech.com 35

18.

Figure 3-1.

Kernel Configuration – Sound

FIC8120 Programming Guide www.faraday-tech.com 36

19.

Figure 3-2.

Kernel Configuration – OSS Sound Modules

After booting the Linux kernel, you can play wave or mp3 audio file. # madplay/audio/demo.mp3

20.

Figure 3-3.

Loading I2S Audio Driver

FIC8120 Programming Guide www.faraday-tech.com 37

The result will look like the one shown in Figure 3-3. You can listen to the music from the speaker that connects to the audio line out.

3.1.3

Driver Internals

This sub-section describes the Linux driver internal design including its features, architecture, and functions.

3.1.3.1

Driver Features

The Open Sound System (OSS) driver supports several codec devices. The audio device is named /dev/dsp. The user application uses /dev/dsp to play its music. The device number definition is as follows.

Table 3-2.

DSP Device Number

Device Name

Major

Minor







/dev/dsp

14

3

FIC8120 Programming Guide www.faraday-tech.com 38

Audio device driver uses the following features for performance and implementation: AHB DMA: Audio driver uses AHB DMA to do data transfer for performance issue. AHB ISR: When DMA completes the data transfer, interrupt service routine is triggered to do the next transaction.

3.1.3.2

Driver Architecture

The Linux audio driver architecture is as shown in Figure 3-4. The file “fac97.c”/”fi2s.c” is the main program of the audio driver. It uses the data structure “audio_driver” and registers the OSS driver by the function “sound_install_audiodrv()”. After the registration is done, OSS layer uses its operation to register device file system. The user application can use audio resource by /dev/dsp.

fs / devfs / base.c

/ dev / dsp

devfs_register_chrdev() struct file_operations* OSS Layer sound_install_audiodrv() struct audio_driver* faudio.c

21.

Figure 3-4.

3.1.3.3

Audio Driver Architecture

Driver Functions

The most important task in the audio driver is to prepare audio driver structure and register OSS driver. Table 3-3 describes the major functions the audio driver implements.

Table 3-3.

I2S Device Functions

Major Function

Description





ssp_open

This routine is called whenever audio port is opened. It enables I2S controller.

FIC8120 Programming Guide www.faraday-tech.com 39

Major Function

Description



ssp_close



This routine is called to close audio driver and release audio resource.



ssp_output_block



This routine is called to give data information for audio driver to send data to audio device.



ssp_start_input

• This routine is called to give data information for audio driver to receive data from audio device.

• ssp_prepare_for_o utput



This routine is called to set up SSP clock division prepared for output

• ssp_prepare_for_ input



This routine is called to set up SSP clock division prepared for input



ssp_halt



This routine is called to halt SSP input or output transfer



ssp_halt_input



This routine is called to halt SSP input transfer



ssp_halt_output



This routine is called to halt SSP output transfer



ssp_trigger



This routine is called to trigger SSP DMA transfer



ssp_set_speed



This routine is called to set up audio device sample rate



ssp_set_bit



This routine is called to set up data size and endianness

• ssp_interrupt_han dler



This routine is called when under-run or over-run event is triggered

• dma_interrupt_ha ndler

• This routine is called when DMA transfer is completed and the interrupt service routine is triggered to do the next transaction



ssp_record



This routine is called to record sound data



ssp_play



This routine is called to play sound data

3.1.4

Reference •

Faraday FTSSP010 Controller Datasheet



FPLAT_RISC_CPE110/MDC1 FIC8120 User Guide



FPLAT_RISC_CPE110/MDC1 FIC8120 Programming Guide



Linux Device Drivers, 2nd Edition Available at website http://www.oreilly.com/catalog/linuxdrive2/chapter/book/index.html



Open Sound System™ Programmer’s Guide Available at website http://www.4front-tech.com/pguide/oss.pdf

3.2 MAC Driver

3.2.1

Introduction

Described below is the implementation of Faraday MAC driver on Linux operating system.

FIC8120 Programming Guide www.faraday-tech.com 40

FIC8120 Programming Guide www.faraday-tech.com 41

3.2.1.1

MAC I/O Resource Overview

Faraday’s MAC I/O resource and memory are briefly listed in Appendix A.

3.2.1.2

Source File Overview

FA526-Linux provides the MAC driver to implement the network function. The related files on Linux are shown in Table 3-4. Please note that is the top path of the kernel source tree.

Table 3-4.

FMAC Source File List

File

Description



/ drivers / net / ftmac100.c



Main program of MAC driver



/ drivers / net / ftmac100.h



Header file for MAC driver



/ net / *



Network protocol source

3.2.2

MAC Driver Guide

To activate Faraday MAC function, you have to select some options in the kernel configuration menu. These options include enabling Linux network support, Ethernet (10 or 100 Mb/s) and then Faraday FTMAC100 support. Figure 3-6 shows the networking support on the kernel configuration (Main Menu -> General Setup). Figure 3-9 shows the Faraday FTMAC100 support (Main Menu -> Network Device Support -> Ethernet (10 or 100 Mb/s) -> Faraday FTMAC100 Support). The option “Faraday FTMAC100-2” is reserved for selection in case two MACs are supported in future platforms. Presently FIC8120 only supports one MAC. Depending on your requirement, you may select your specified network protocol from the option “Networking options.” After the configuration is finished, you can make your kernel for Faraday MAC driver support.

FIC8120 Programming Guide www.faraday-tech.com 42

22.

Figure 3-5.

Kernel Configuration – General Setup

23.

Figure 3-6.

Kernel Configuration – General Setup -> Networking Support

FIC8120 Programming Guide www.faraday-tech.com 43

24.

Figure 3-7.

Kernel Configuration – General Setup -> Networking Support (1)

25.

Figure 3-8.

Kernel Configuration – General Setup -> Networking Support (2)

FIC8120 Programming Guide www.faraday-tech.com 44

26.

Figure 3-9.

Kernel Configuration for Faraday FTMAC100 Support

After compiling Linux kernel with these options, Linux will run and the terminal will show a booting message as shown in Figure 3-10. You can see the FTMAC100 description in the booting message if it works. When the shell starts, you can do some network test. For example, you can execute the following commands to set up the Ethernet MAC address and IP address: # ifconfig eth0 hw ether 00:11:22:33:44:55 # ifconfig eth0 192.168.121.139 Or try to ping another network device by the following command: # ping 192.168.121.70 The results of these commands look like the one shown in Figure 3-11. Now, you can start to use network function.

FIC8120 Programming Guide www.faraday-tech.com 45

27.

Figure 3-10.

Linux Booting Message – MAC

28.

Figure 3-11.

Use of Network Device – ifconfig, ping

FIC8120 Programming Guide www.faraday-tech.com 46

3.2.3

Driver Internals

This section describes the Linux driver internal design including its features, architecture, and functions.

3.2.3.1

Driver Features

Linux MAC driver uses the device name “/dev/eth” for user applications. You do not have to create “/dev/eth” because it is dynamically created. The MAC device driver uses its DMA feature to transmit or receive packets. It implements interrupt service routine to handle Rx FIFO data or error.

3.2.3.2

Driver Architecture

The Linux MAC driver architecture is as shown in Figure 3-12. The file “ftmac100.c” is the main program of the network device driver. It implements network device operations and processes data from and to the protocol layer. User application uses socket to program its network functions.

U s e r A p p lic a tio n

s o c k e t fu n c tio n

S o c k e t In te rfa c e

N e tw o rk P ro to c o l S ta c k s / n e t / *

n e tif_ rx () s tru c t n e t_ d e v ic e *

ftm a c 1 0 0 .c

R J45

29.

3.2.3.3

Figure 3-12.

FMAC Driver Architecture

Driver Functions

The most important task of the MAC driver is to implement net_device operations. Table 3-5 describes the major functions in "ftmac100.c”. You may refer to the source code to obtain more detailed

FIC8120 Programming Guide www.faraday-tech.com 47

information.

FIC8120 Programming Guide www.faraday-tech.com 48

Table 3-5.

FMAC Driver Functions

Major Function

Description



ftmac100_init



Initialize FTMAC100 device



ftmac100_open



The kernel calls this function when someone wants to use the network device



ftmac100_close



Clean up everything that the open routine does and put it into the power-down state



ftmac100_interrupt



Interrupt service routine to handle different situations according to MAC status



ftmac100_rcv



Receive packets from MAC and forward data to protocol layer



ftmac100_probe



Perform typical initialization tasks and set up private data



ftmac100_reset



Set the MAC to its normal state, clear all interrupts and then wait for finish of the reset



ftmac100_enable



Enable the transmitter, receiver and interrupts

3.2.3.4

MII interface Support

You can use "ethtool" utility in file system to change the MAC media type in user space. For example, "# ./ethtool -s eth0 speed 10 duplex half autoneg off".

3.2.4

Reference •

Faraday FIC8120_DS_v*.* Data Sheet



Linux Device Drivers, 2nd Edition Available at website http://www.oreilly.com/catalog/linuxdrive2/chapter/book/index.html

3.3 Serial Driver

3.3.1

Introduction

Described below is the implementation of Faraday serial driver on Linux operating system.

3.3.1.1

Serial I/O Resource Overview

Faraday’s serial I/O resource and memory are briefly listed in Appendix A. Please refer to Table 3-6 for UART clock setting.

FIC8120 Programming Guide www.faraday-tech.com 49

Table 3-6.

UART Clock Platform

Device •

UART clock

3.3.1.2

FIC8120 •

22.1184 MHz

Source File Overview

FA526-Linux provides the UART driver to implement the tty/console driver. The related files on Linux are shown in Table 3-7. Please note that is the top path of the kernel source tree.

Table 3-7.

UART Source File List

File

Description



/drivers/char/serial_cpe.c



Faraday UART serial driver main program



/include/asm/arch-cpe/cpe/fic8120.h



Definition of baud rate



/include/asm-arm/arch-cpe/cpe/serial.h



Header file of serial port definition

3.3.2

Serial Driver Guide

To activate Faraday UART function, you have to select some options in the kernel configuration. These options include enabling serial port, setting its baud rate to 38400 and selecting UART1 to be the kernel console port. Figure 3-13 shows the UART clock setting on the kernel configuration (Main Menu -> System Type). Figure 3-15 shows the serial port support (Main Menu -> Character Devices).

FIC8120 Programming Guide www.faraday-tech.com 50

30.

Figure 3-13.

Kernel Configuration – System Type

31.

Figure 3-14.

Kernel Configuration – UART Clock

FIC8120 Programming Guide www.faraday-tech.com 51

32.

Figure 3-15.

Kernel Configuration – Character Devices

33.

Figure 3-16.

Kernel Configuration – CPE Serial Port Support

After compiling Linux kernel with these options, Linux will run and the terminal will show a booting message as shown in Figure 3-17. You can see the Faraday UART description in the booting message

FIC8120 Programming Guide www.faraday-tech.com 52

if it works. Note that the terminal on the host must be set to the same baud rate as the target.

34.

Figure 3-17.

3.3.3

Linux Booting Message – Serial

Driver Internals

This section describes the Linux driver internal design including its features, architecture, and functions.

3.3.3.1

Driver Features

Linux UART driver uses the device name “/dev/ttyS”. The major number of ttyS is 4 and the minor number starts from 64. Table 3-8 shows the device name used and its device number.

Table 3-8.

UART Device Number

Device Name

Major

Minor



/dev/ttyS0



4



64



/dev/ttyS1



4



65

FIC8120 Programming Guide www.faraday-tech.com 53



/dev/ttyS2



4



66



/dev/ttyS3



4



67

The UART device driver does not use any DMA feature. It implements interrupt routine to service Rx FIFO data.

FIC8120 Programming Guide www.faraday-tech.com 54

3.3.3.2

Driver Architecture

The Linux UART driver architecture is as shown in Figure 3-18. The file “serial_cpe.c” is the main program of the UART driver. It provides the data structure “tty_driver” and registers the tty driver by the function “tty_register_driver()”. After registering the tty driver, the function “register_chrdev()” is called to register the character device. After the registration is done, the user program can use the UART function through “dev/ttyS0”.

fs/device.c /dev/ttyS0

register_chrdev()

struct file_operations*

tty_io.c tty_register_driver()

struct tty_driver*

serial_cpe.c

35.

Figure 3-18.

3.3.3.3

UART Driver Architecture

Driver Functions

The most important task of the UART driver is to prepare the tty_driver structure and register the tty driver. Table 3-9 describes the “tty_driver” structure and the major functions implemented by “serial_cpe.c”. You may browse the source code to get more details.

Table 3-9.

UART Driver Functions

Major Function

Description



rs_open

• This routine is called whenever a serial port is opened. It enables interrupts for a serial port.



rs_close



This routine is called when the serial port gets closed.



rs_write



This routine is called to write data to tty driver buffer before writing to UART.

FIC8120 Programming Guide www.faraday-tech.com 55

Major Function

Description



rs_flush_chars

• This routine is called by the kernel after writing a number of characters to the tty device using put_char.



rs_ioctl



This routine is called to set or get some control parameters.



rs_write_room



This routine returns the number of characters the tty device will accept for writing.



rs_chars_in_buffer



This routine returns the number of characters the tty device has buffered.



rs_throttle



This routine tells the tty driver that the input buffers of the line discipline are close to full.



rs_unthroottle

• This routine tells the tty driver that the input buffers of the line discipline have enough space.



rs_send_xchar



This routine is used to send a high-priority XON-XOFF character to the device.



rs_set_termios



This routine is used to notify the tty driver of a change of “termios”.



rs_stop



This routine stops the tty driver from sending out characters to the tty device.



rs_start



This routine enables the tty driver to start sending out characters to the device.



rs_read_proc



This routine is used to read tty information from /proc file system.



rs_write_proc



This routine is used to write tty information from /proc file system.



rs_interrupt_single



Serial driver’s interrupt routine for a single port.

3.3.4

Reference •

Faraday UART and IrDA Controller Specification



Linux Device Drivers, 2nd Edition Available at website http://www.oreilly.com/catalog/linuxdrive2/chapter/book/index.html

3.4 SD Driver

3.4.1

Introduction

Described below is the implementation of Faraday SD/MMC driver on Linux operating system, designed to let you have a clear understanding of the SD/MMC driver design and its hardware information.

3.4.1.1

SD/MMC I/O Resource

The I/O and interrupt resources of Faraday’s SD/MMC IP are listed in Appendix A.

FIC8120 Programming Guide www.faraday-tech.com

56

3.4.1.2

Source File Overview

To activate the SD/MMC functions, you must provide Linux SD/MMC driver source code in FA526-Linux kernel. The related files are shown in Table 3-10.

Table 3-10.

SD Source File List

File

Description

• .h

/drivers/block/CPESD/sd



Definitions related to Linux SD/MMC driver

• .c

/drivers/block/CPESD/sd



Main code of Linux SD/MMC driver

3.4.1.3

Driver Features

Linux SD/MMC driver is based on the device node “/dev/cpesda” for user applications. Detailed information is shown in the following table.

Device Name

Major

Minor



/dev/cpesda



6



0



/dev/cpesdb



6



1

Please note that the SD/MMC driver supports hot-swap operation. You can insert and remove the SD/MMC card at any time. However, you should never hot-swap the SD/MMC card when it is reading or writing.

3.4.2

3.4.2.1

SD/MMC Driver Guide

Kernel for SD/MMC Driver

In order to be compatible with modern USB SD card reader on PC platform, the SD/MMC driver should additionally add some options to support MSDOS and VFAT file system as shown in Figure 3-19 and Figure 3-20.

FIC8120 Programming Guide www.faraday-tech.com

57

36.

Figure 3-19.

Kernel Configuration – File Systems

37.

Figure 3-20.

Kernel Configuration – MSDOS File Systems

3.4.2.2

User Applications for SD/MMC Driver

After the kernel and user shell get started, you can execute script “./ffmpeg/mountsd_bat” to load SD driver, create device node and mount the device. Please refer to Figure 3-21 for the contents of the script “./ffmpeg/mountsd_bat”.

FIC8120 Programming Guide www.faraday-tech.com

58

38.

Figure 3-21.

SD Driver Auto-Load Script

After that, you can change directory to /mnt/sddisk/ and then perform file read/write.

3.4.3

Driver Internals

This section describes the Linux SD/MMC driver internal design including its features, architecture, and operations.

3.4.3.1

Driver Architecture 格式化: 緊縮 0.1 pt

The Linux SD/MMC driver architecture is as shown in Figure 3-22. The file “cpesd.c” is the main code of

刪除: Figure 3-22

the SD/MMC driver. It implements SD/MMC function and processes data between file systems and SD

格式化: 不使用拼字或文法檢 查, 緊縮 0.1 pt

controller. User application can access the data in the SD/MMC card directly via the SD/MMC driver or file

格式化: 緊縮 0.1 pt

systems.

FIC8120 Programming Guide www.faraday-tech.com

59

U s e r A p p lic a tio n s

F ile S y ste m s

/d e v/cp e s d a cpesd.c

S D C o n tro lle r

S D / M M C C a rd

39.

Figure 3-22.

3.4.3.2

SD/MMC Driver Architecture

Driver Functions

Table 3-11 lists the major functions in “sd.c”.

Table 3-11.

SD Device Functions

Major Function

Description



sd_module_init()

• Register the driver as a block driver with major number 6 and initialize some standard parameters for block driver



sd_module_cleanup()



Un-register the driver and release allocated resources



sd_card_setup()



Initialize SD controller and re-read the SD/MMC card information



sd_request()



Treat the block requests for the SD/MMC block driver



sd_transfer()



sd_revalidate()



Re-validate SD/MMC card status and get its information after mounted



sd_dma_interrupt_handler()



Handle DMA interrupt

• ()

sd_hotswap_interrupt_handler



Handle SD/MMC card hot-swap interrupt



sd_ioctl()



Specific IOCTL functions of SD/MMC block driver



sd_open()



SD/MMC block driver startup function



sd_release()



SD/MMC block driver release function

FIC8120 Programming Guide www.faraday-tech.com

60



sd_check_change()



SD/MMC block driver media check function

FIC8120 Programming Guide www.faraday-tech.com

61

3.4.4

User Applications for SD/MMC Driver

After the kernel and user shell are started, you should check the device node “/dev/cpesda” for the SD/MMC driver. If the device node does not exist, you should refer to the following commands to create it: # mknod /dev/cpesda b 6 0 Now, you can plug an SD or MMC card into the CPE SD/MMC slot. If the SD or MMC card is a new one, you can use the “mkdosfs” command to format it. # mkdosfs /dev/cpesda “/dev/cpesda” is the same as many block devices and you can use many block commands such as “mount/cp/mkdir/…” to access the SD or MMC cards. # mount –t msdos /dev/cpesda /mnt Now you can operate the SD card as a file directory. # ls /mnt After that, you may read the file “/etc/inittab” from the SD/MMC card reader on PC.

3.4.5

Make module method

Our Linux package SD driver type is module, so if you want to compiler driver again, please write “make modules” after you compiler kernel ready. Or you can change xconfig SD driver setting from “M” to “*” and compiler again, and our CPESD_DMA.o driver only change name form sd.o

3.4.6

Reference •

Faraday SD Memory Host Controller Data Sheet



SD Memory Card Specifications Part 1: Physical Layer Specification Part 2: File System Specification



Linux Device Drivers, 2nd Edition Available at website http://www.oreilly.com/catalog/linuxdrive2/chapter/book/index.html

FIC8120 Programming Guide www.faraday-tech.com

62

3.5 LCD Driver Described below is the implementation of Faraday FTLCDC100 LCD frame buffer driver on Linux operation system.

FIC8120 Programming Guide www.faraday-tech.com

63

3.5.1.1

LCD I/O Resource

The I/O resources of Faraday FTLCDC100 IP are listed in Appendix A.

3.5.1.2

Source File Overview

To activate the LCD functions, you have to provide LCD frame buffer driver source code in FA526-Linux kernel. The related files are shown in the following table. Please note that is the top path of the kernel source tree.

Table 3-12.

LCD Source File List

File

Description



/drivers/video/pl110fb.h



Definitions related to Linux LCD driver



/drivers/video/flcd.c



Main code of Linux LCD driver

3.5.2

3.5.2.1

LCD Driver Guide

Kernel for LCD Driver

To activate Faraday LCD function, you have to select some options in the kernel configuration menu. Please refer to the following figures to set up LCD frame buffer driver (by the command “make menuconfig”).

40.

Figure 3-23.

Kernel Configuration – Character Devices

FIC8120 Programming Guide www.faraday-tech.com

64

41.

Figure 3-24.

Kernel Configuration – Enable Virtual Terminal

42.

Figure 3-25.

Kernel Configuration – Console Drivers

FIC8120 Programming Guide www.faraday-tech.com

65

43.

Figure 3-26.

Kernel Configuration – Enable Faraday FTLCDC100 LCD Controller and set output format

FIC8120 Programming Guide www.faraday-tech.com

66

44.

Figure 3-27.

Kernel Configuration – Set LCD panel module

45.

Figure 3-28.

Kernel Configuration – Enable 16 bpp Packed Pixels Support

After configuration, you should make the kernel image, upload kernel to target system and boot it. With the LCD frame buffer driver, you should see a penguin at the top left corner of the LCD monitor.

FIC8120 Programming Guide www.faraday-tech.com

67

3.5.3

Driver Internals

This section describes the Linux LCD frame buffer driver internal design including its features, architecture, and operations.

3.5.3.1

Driver Features

Linux LCD frame buffer driver is based on device node “/dev/fb*” for user applications. The detailed information is shown in the following table.

Table 3-13.

LCD Driver Device Node

Device Name

Major

Minor







/dev/fb0

3.5.3.2

29

0

Driver Architecture

This section describes Linux LCD frame buffer driver architecture as shown in the following figure. The file “flcd.c” is the main code of LCD frame buffer driver. It implements LCD function and processes data between GUI system and frame buffer.

Console.c

Vgacon.c

Low Level Drivers

Fbcon.c

Fbcon-afb.c Fbcon-cfb8.c ...

Abstract Console Driver

Gspcon.c

Amifb.c flcd.c

Frame Buffer Devices

...



46.

Figure 3-29.

LCD Driver Architecture.

FIC8120 Programming Guide www.faraday-tech.com

68

3.5.3.3

Driver Functions

Table 3-14 describes the major functions in “flcd.c”.

Table 3-14.

LCD Driver Functions

Major Function

Description



flcd_init



Initialize Faraday FTLCDC100 LCD controller



flcd_map_video_memory



Allocate the DRAM memory for the frame buffer



flcd_blank



Function called when kernel wants to blank LCD monitor



flcd_switch



The kernel calls this function when it wants to change to the specified console.



flcd_get_cmap



The kernel calls this function when it wants to get color map.



flcd_set_cmap



The kernel calls this function when it wants to set color map.



flcd_set_var



Set the user defined part of the display for the specified console



flcd_get_var



Get the user defined part of the display for the specified console



flcd_get_fix



Get the fixed part of the display for the specified console



flcd_setcolreg



Set palette for the console

3.5.3.4

Driver IOCTL command for Application

The IOCTL command as follow:

IOCTL Command • define FLCD_GET_DATA_SEP

Description 0x46db

• t will get LCD flcd_data value • truct flcd_data • • nsigned int phy_start_addr; • nsigned int user_start_addr; • nsigned int buf_len; • nsigned int frame_no; • nsigned int mp4_map_dma[CONFIG_PP_FRAME_NO]; • ;





FIC8120 Programming Guide www.faraday-tech.com

69

IOCTL Command

Description

define FLCD_SET_FB_NUM

0x46dd

• define FLCD_SWITCH_MODE

0x46de

• define FLCD_SET_SPECIAL_FB • define FOSD_ON

0x46df

0x46e6

• define FOSD_OFF

0x46e7

t will set frame buffer to 0~n and display to LCD, it will be trigger by interrupt happen • t will switch to FLCD_MODE_YCBCR or FLCD MODE_RGB, FLCD MODE_RGB = 0, FLCD_MODE_YCBCR = 1 • t will set frame buffer to 0~n and display to LCD • t will enable OSD function • t will disable OSD function

• define FOSD_SETPOS

0x46e1

• t will set OSD position value

• define FOSD_SETDIM

0x46e2

• t will set OSD dimension value

• define FOSD_SETSCAL

0x46e3

• t will set OSD scaling value

• define LCD_SET_TRANSPARENT 0x46e4

• t will set OSD transparency control level

• define FLCD_SET_STRING 0x46e5

• t will set OSD string structure value

struct fosd_string { unsigned int Str_row; // Character address in memory, start address is zero, second string unsigned int display_mode; // RGB or YCbCr mode unsigned int fg_color; // String foreground color unsigned int bg_color; // String background color unsigned char Str_OSD[30]; // String length, only support length 30 }; struct fosd_data { unsigned int Hs; // Horizontal position unsigned int VPos; // Vertical position unsigned int HDim; // Horizontal dimension unsigned int VDim; // Vertical dimension unsigned int transparent_level; // Transparency control level unsigned int HScal; // Horizontal scaling unsigned int VScal; // Vertical scaling

FIC8120 Programming Guide www.faraday-tech.com

70

struct fosd_string Str_Data[10]; // Display string, only support 10 string one frame };

FIC8120 Programming Guide www.faraday-tech.com

71

3.5.4

Reference •

Faraday FIC8120 Platform Specification



The Linux Frame Buffer Device Subsystem Available at website http://home.tvd.be/cr26864/Linux/fbdev/ Linux Device Drivers, 2nd Edition



Available at website http://www.oreilly.com/catalog/linuxdrive2/chapter/book/index.html

3.6

PCI Driver

3.6.1

Introduction

Described below is the implementation of PCI driver on Linux operation system, designed to let you have a clear understanding of the LCD frame buffer driver design and its hardware information.

3.6.1.1

PCI Resource Overview

Faraday’s PCI I/O resource and memory are briefly listed in Appendix A.

3.6.1.2

Source File Overview

To activate the PCI functions, you have to provide PCI driver source code in FA526-Linux kernel. The related files are shown in the following table. Please note that is the top path of the kernel source tree.

Table 3-15.

PCI Source File List

File

Description



/include/asm/arch/cpe/ftpci.h



Definitions related to Linux PCI driver

• i.c

/arch/armnommu/mach-cpe/ftpc



Main code of Linux PCI driver

3.6.2

PCI Driver Guide

FIC8120 Programming Guide www.faraday-tech.com

72

3.6.2.1

Kernel for PCI Driver

To activate Faraday PCI function, you have to select some options in the kernel configuration menu. Please refer to the following figures to set up PCI driver (by the command “make xconfig”).

47.

48.

Figure 3-30.

Kernel Configuration – General Setup

Figure 3-31.

Kernel Configuration – Enable PCI Support

After configuration, you should make the kernel image, upload kernel to target system and boot it.

FIC8120 Programming Guide www.faraday-tech.com

73

3.6.3

Verifying by Realtek 8139d Chip PCI Network Card

We use a Realtek 8139d chip PCI network card to test whether PCI controller is functional. To support this card, you have to select some options in the kernel configuration menu. Please refer to the following figures to add support for Realtek 8139d chip PCI network card (by the command “make xconfig”).

49.

Figure 3-32.

Kernel Configuration – Network Device Support

50.

Figure 3-33.

Kernel Configuration – Ethernet (10 or 100 Mbit)

FIC8120 Programming Guide www.faraday-tech.com

74

51.

Figure 3-34.

Kernel Configuration – RealTek PCI Card

After compiling Linux kernel with these options, Linux will run and the terminal will show a booting message as shown in Figure 3-35. You can see the RTL8139 description in the booting message if it works. When the shell starts, you can do some network test. For example, you can execute the following commands to set up the Ethernet MAC address and IP address: # ifconfig eth0 hw ether 00:11:22:33:44:55 # ifconfig eth0 192.168.131.151 Then you can check connection status by “ifconfig” command. Try to ping another network device by the following command: # ping 192.168.131.40 The result will look like the one shown in Figure 3-36. Now, you can start to use the network function.

FIC8120 Programming Guide www.faraday-tech.com

75

52.

Figure 3-35.

Ethernet Card Initialize Status

53.

Figure 3-36.

Verifying Connection of Ethernet by Ping

FIC8120 Programming Guide www.faraday-tech.com

76

3.6.4

Driver Internals

This section describes the Linux PCI controller driver internal design including its features, architecture, and operations.

3.6.4.1

Driver Architecture

The architecture of Linux PCI subsystem is shown in the following figure. The PCI subsystem in Linux is divided into three logical parts: •

PCI Device Driver



PCI BIOS



PCI Fixup

Where the “PCI Device Driver” part searches the PCI system starting at Bus 0 and locates all PCI devices and bridges in the system, building a linked list of data structures describing the topology of the system. The “PCI BIOS” part provides services described in pci-bios specification. The “PCI Fixup” part implements system specific part of PCI. The file “ftpci.c” is the main code of PCI controller driver, which is system specific. Its primary function is to initialize PCI controller and provide some basic functions to access PCI configuration space.

PCI PCI device driver driver PCI fixup PCI fixup PCI bios bios PCI

PCI card driver

PCI card driver

Ftpci.c Ftpci.c

PCI card PCI card

54.

Figure 3-37.

PCI Driver Architecture

FIC8120 Programming Guide www.faraday-tech.com

77

3.6.4.2

Driver Functions

Table 3-16 describes the major functions in “ftpci.c”.

Table 3-16.

PCI Driver Functions

Major Function

Description



ftpci_init



Initialize Faraday PCI controller



cpe_map_irq



Map the specified device/slot/pin to an IRQ



ftpci_setup_resource



Set up I/O and memory resource to be assigned to PCI device later



ftpci_read_config_byte



Read a byte from configuration space



ftpci_read_config_word



Read a word from configuration space

• d

ftpci_read_config_dwor



Read a word from configuration space



ftpci_write_config_byte



Write a byte to configuration space



ftpci_write_config_word



Write a word to configuration space

• d

ftpci_write_config_dwor



Write a word to configuration space

3.6.5

Reference •

Faraday FIC8120 Platform Specification



Linux PCI Available at website http://www.science.unitn.it/~fiorella/guidelinux/tlk/node65.html#SECTION00800000000000000 000



Linux Device Drivers, 2nd Edition Available at website http://www.oreilly.com/catalog/linuxdrive2/chapter/book/index.html

3.7 Capture Application

3.7.1

Introduction

Described below is the execution of Faraday capture demo program.

FIC8120 Programming Guide www.faraday-tech.com

78

3.7.2

55.

Configuration Setting

Figure 3-38.

Kernel Configuration for Capture Program

Before you run this program, you must enable Faraday TV / LCD or VGA item and configure display mode. After compiling Linux kernel with these options, Linux will run and the terminal will show a booting message as shown below. You can see the message if it works.

FIC8120 Programming Guide www.faraday-tech.com

79

3.7.3

Work Flow init LCD open("/dev/fb0", O_RDWR) init capture open("/dev/video0", O_RDWR)

ioctl(video_fd,VIDIOCGMBUF,&gb_buffers)

read_key= q?

Yes

Exit

No

capture_sync

show_lcd

ioctl(video_fd, VIDIOCSYNC, &gb_frame)

Capture driver fcap_sync() to check data ready

Copy capture YUV data to map and tune address to 720x480 panel

Once the data input is ready, you can capture the driver mode from CMOS censor or TV_in by copy Y/U/V base address to LCD display and tune the address to meet 720x480 display size. If you wish to capture the 640x480 image, you must copy the 640 bytes to LCD memory and shift 80 bytes address to next line.

3.7.4

Result

# cd ffmpeg/ /ffmpeg # ./ffmpeg -focus 640x480 Main Thread ID = 20 Press [q] to stop previewing 0x84

q

0x85

/ffmpeg #

/ffmpeg # •

FIC8120 Programming Guide www.faraday-tech.com

80

3.7.5

Reference •

Faraday FIC8120 MPEG4 JPEG AP User Guide

3.8 TV Encoder Driver Application

3.8.1

Introduction

Described below is the execution of Faraday TV encoder demo program.

3.8.2

56.

Configuration Setting

Figure 3-39.

Kernel Configuration for TV Encoder Program

FIC8120 Programming Guide www.faraday-tech.com

81

57.

Figure 3-40.

Kernel Configuration for TV Encoder Program (1)

Before running this program, you must enable Faraday TV encoder item with default display mode set at YUV. After compiling Linux kernel with these options, Linux will run and the terminal will show a booting message. The Video endpoint is linked with TV-out port. You can see the message if it works, and the picture is displayed on TV screen too. (Please note that this is a software decode JPEG file, not an MP4 hardware decode method.)

3.8.3

Work Flow



# ls 1.jpg

4.jpg

display_tv.sh

2.jpg

5.jpg

display_ycbcr.sh

24toycbcr

6.jpg

ycbcrshow

3.jpg

convert

tmp.miff tmp.rgb tvshow

# ./display_tv.sh 1.jpg convert: UnableToOpenConfigureFile. convert: UnableToOpenConfigureFile. #

FIC8120 Programming Guide www.faraday-tech.com

82

display_tv.sh file •

./convert $1 tmp.miff



./24toycbcr 420 tmp.miff tmp.rgb



./tvshow tmp.rgb

Note: You must convert 24toycbcr and tvshow execution files to proceed.

3.9 Audio Two-Way Application

3.9.1

Introduction

Described below is the execution of Faraday audio two-way demo program.

3.9.2

58.

Configuration Setting

Figure 3-41.

Kernel Configuration for Audio Driver

Before running this program, you must enable Faraday audio driver and compile Linux kernel with this option. To use full duplex audio function, you have to create two devices /dev/dsp and /dev/dsp1. The two devices can perform play and record function with the same sampling rate at the same time.

FIC8120 Programming Guide www.faraday-tech.com

83

3.9.3

Work Flow •

Play audio from PC or DVD, and then plug the line in.



Move to tmp directory and run audio.sh. vrec2 -wS -t 20 -s 32000 -b 16 test.wav & The audio program vrec2 uses /dev/dsp1 to be the driver device.



Play audio like “vplay 32k.wav” from FIC8120 platform. The audio program vplay uses /dev/dsp to be the driver device.



Play the previously recorded “test.wav”.

Argument: •

-ws



Wave stereo



20



Record time (sec)



32000

• Sample rate (32000 or 22050, normally defined)



-b 16



Bit 16 (only support 16 bits, CODEC issue)

Only supports PCM for record format.

3.10 Audio Player Application

3.10.1 Introduction Described below is the execution of Faraday Audio Player – mp3, AAC, WMA programs.

FIC8120 Programming Guide www.faraday-tech.com

84

3.10.2 Configuration Setting

59.

Figure 3-42.

Kernel Configuration for Audio Driver

Before running this program, you must enable Faraday audio driver and compile Linux kernel with this option.

3.10.3 Work Flow Play MP3 Command Play => ./fmad xxx.mp3 /dev/dsp 0 Exit => Ctrl + C Result ====================================== Faraday MPEG Audio Decoder (FMAD) V1.0 Demo Version ====================================== 00:00:12, Layer 3, 128 kbps, 44100 kHz, stereo, Normal Demo version limitation: •

Bit rate:

192,128 bps /MPEG1,MPEG2 12,896 bps /MPEG2.5



Can only play 6 min /44.1 kHz

FIC8120 Programming Guide www.faraday-tech.com

85

Play AAC Command Play => ./faac 1.m4a /dev/dsp 0 Exit => Ctrl + C

Result ===================================================== Faraday MPEG-4 AAC Decoder (FAAC-MP4) V1.0 Demo Version ===================================================== 1.m4a file info: LC AAC 199.427 secs, 2 ch, 44100 Hz 44100 Hz, 2 ch, 138 kbps, 00:00:04

Demo version limitation: •

Bit rate: MPEG2 AAC



Can only play for 3 minutes

Play WMA Command Play => ./fwma test.wma /dev/dsp Exit => Ctrl + C

Result ===================================================== Faraday Windows Media Audio V8 Decoder (FWMA8) V0.1 ===================================================== 44100 khz, stereo, 64 kbps, No DRM, 00 : 00 : 05

Demo version limitation: •

Can only play for 3 minutes

FIC8120 Programming Guide www.faraday-tech.com

86

3.11 IDE Driver Guide

3.11.1 Introduction This document describes how Faraday CPE platforms support IDE devices on Linux operating system. You have to provide two interfaces to IDE device, but only one can be used at a time. Therefore, only information necessary for enabling IDE devices on Faraday’s CPE platforms is provided below. The 1-inch MicroDrive with IDE interface default mode is master

3.11.1.1 IDE I/O Resource The I/O and interrupt resources for Faraday IDE controller on Faraday’s platforms – FIC8120 – is described below. It is the responsibility of the IDE driver to allocate the resources. Please refer to Table 格式化: 使用拼字與文法檢查

3-17 and Table 3-18 for detailed information.

格式化: 使用拼字與文法檢查 刪除: Table 3-17

Table 3-17.

FIC8120





Table 3-18.

27 (IRQ)

PCIDE I/O Memory

Platform Device

FIC8120





IDE

格式化: 使用拼字與文法檢查 刪除: Table 3-18

Platform Device IDE

格式化: 使用拼字與文法檢查

IDE Interrupt Number

0x91400000

3.11.1.2 Source File Overview Linux kernel has provided thorough IDE driver source codes. Before reading them, you should have the ATAPI specifications in hand. The related files are shown in the path “/drivers/ide/*.*”. Please note that is the top path of the kernel source tree.

FIC8120 Programming Guide www.faraday-tech.com

87

Table 3-19.

IDE Source File List

File

Description



/drivers/ide/ide.c



Main code of Linux IDE driver



/drivers/ide/ide-disk.c



IDE/ATA disk driver



/drivers/ide/ide-feature.c



Configure and check drive speed



/drivers/ide/ide-probe.c



IDE probe module to find interface and device



/drivers/ide/cpeide.c



Faraday IDE controller driver

3.11.2 IDE Driver Guide

3.11.2.1 Kernel for IDE Driver To allow Faraday’s platforms, FIC8120, to support IDE devices, you have to select some options in the kernel configuration menu (by the command “make xconfig”). Please refer to Figure 3-43 through Figure 3-47 for the IDE driver setup.

60.

Figure 3-43.

Kernel Configuration – ATA/ATAPI/MFM/RLL Support

FIC8120 Programming Guide www.faraday-tech.com

88

61.

Figure 3-44.

Kernel Configuration – IDE, ATA and ATAPI Block Devices

62.

Figure 3-45.

Kernel Configuration – Include IDE/ATA-2 DISK Support

FIC8120 Programming Guide www.faraday-tech.com

89

63.

Figure 3-46.

Kernel Configuration – Faraday FTIDE020_S Support (PIO Mode)

64.

Figure 3-47.

Kernel Configuration – Faraday FTIDE020_S Support (DMA Mode)

FIC8120 Programming Guide www.faraday-tech.com

90

After configuration, you should make the kernel image, upload the kernel to the target system and boot it. With the IDE driver, you would read the booting messages as shown in Figure 3-48 with PIO mode 刪除: Figure 3-49

enabled and Figure 3-49 with DMA mode enabled.

65.

Figure 3-48.

Linux Booting Message – IDE Driver with PIO Mode

FIC8120 Programming Guide www.faraday-tech.com

91

66.

Figure 3-49.

Linux Booting Message – IDE Driver with DMA Mode

3.11.2.2 User Applications for IDE Driver After the kernel and user shell are started, you should check the device nodes ”/dev/hda* ~ /dev/hdb*” for the IDE devices. If the device nodes do not exist, you should refer to the following commands to create them:

# cd /dev # mknod hda b 3 0 # mknod hda1 b 3 1 # mknod hdb b 3 64 # mknod hdb1 b 3 65 The device nodes accessed by applications depend on the IDE connection. If your IDE device is a master device connected to the first connector of a cable, the IDE device will be presented in “/dev/hda”. If there is an IDE hard disk without partitioning, you may use the “fdisk” command to create partitions and “mkdosfs” command to format it for instant testing.

FIC8120 Programming Guide www.faraday-tech.com

92

# fdisk /dev/hda # mkdosfs /dev/hda1 # mount –t msdos /dev/hda1 /mnt # umount /dev/hda1

3.11.3 Driver Internals This section describes the Linux IDE driver internal design including its features, architecture, and operations.

3.11.3.1 Driver Features Linux IDE driver is based on the device node “/dev/hd*” for user applications. Detailed information is shown in Table 3-20.

Table 3-20.

IDE Driver Device Node

Device Name

Major

Minor



/dev/hda



3



0



/dev/hda1



3



1



/dev/hdaX



3



X



/dev/hdb



3



64



/dev/hdb1



3



65



/dev/hdbX



3



X+64



/dev/hdc



22



0



/dev/hdc1



22



1



/dev/hdcX



22



X



/dev/hdd



22



64



/dev/hdd1



22



65



/dev/hddX



22



X+64

FIC8120 Programming Guide www.faraday-tech.com

93

3.11.3.2 Driver Architecture The Linux IDE driver architecture is as shown in Figure 3-50. The file “ide.c” is the main code of the IDE driver. It implements IDE function and processes data between file systems and IDE controller. User applications can access the data in the IDE devices directly via the IDE driver or file systems.

User Applications

File Systems

/dev/hd* ide.c

IDE Controller

IDE Devices

67.

Figure 3-50.

IDE Driver Architecture

3.11.3.3 Driver Functions As mentioned above, before tracing the IDE source code, please refer to the ATAPI specification and the related Linux kernel documents. Table 3-21 lists the major functions in “cpeide.c”.

Table 3-21.

IDE Device Functions

Major Function

Description



ide_probe_for_cpeide()

• Initializes IDE controller state and register the device information to hardware interface structure



cpeide_tune_drive()



Routine to tune PIO mode for drives

FIC8120 Programming Guide www.faraday-tech.com

94

Major Function

Description



cpeide_tune_chipset()



Routine to retune DMA modes for drives



cpeide_selectproc ()



Tweaks hardware to select drive



cpeide_set_xfer_mode()



Configures drive speed and set correct timing configuration



set_mode_timing()



Sets timing register



cpeide_dmaproc()



Routine to serve DMA request



cpeide_dma_intr ()



Handler for disk read/write DMA interrupts

3.11.4 Reference •

ATA/ATAPI specification



Linux Device Drivers, 2nd Edition

3.12 USB OTG Device Driver 3.12.1 Introduction Described below is the implementation of Faraday USB OTG device driver on Linux operating system.

3.12.2 Peripheral Module Init/Remove Sequence z Init Sequence:

FIC8120 Programming Guide www.faraday-tech.com

95

z

z

Major Function

Description

FTC_usb_probe()

Driver entry point

vUsbInit()

Configure FIFO and endpoint map

vFOTG200_Dev_Init()

Initialize HW setting

Remove Sequence:

Major Function

Description

FTC_usb_remove()

Tear down the binding between this driver and the pci device

FTC_free_buffer()

Free allocated buffers

Interrupt Handle Sequence

FIC8120 Programming Guide www.faraday-tech.com

96

Major Function

Description

vUsb_rst()

Process the event about Bus Reset

vUsb_suspend()

Process the event about Bus Suspend

vUsb_resm()

Process the event about Bus Resume

dma_advance()

Process the event about dma complete

vUsb_ep0setup()

Process the event after receiving control command data

vUsb_ep0end()

Process the event after receiving Control-End packet

vUsb_ep0tx()

Process the event after receiving Control-In packet

FIC8120 Programming Guide www.faraday-tech.com

97

vUsb_ep0rx()

Process the event after receiving Control-Out packet

vUsb_ep0fail()

Process the event after receiving error from HW (Detail please reference HW datasheet)

EP_ISR()

Process the event after receiving interrupt from the ED

3.12.3 Configure OTG Function We provide two methods to enable FOTG200 : built-in or modulation; for each method, we can enable FOTG200 full function, Host only function, or peripheral function only, the detailed will described configuration & operation procedure in following section. Using “make xconfig” to configure these options. 3.12.3.1 Built-in FOTG200 full function <1> Select the “USB support” button

<2> Select the “Support for USB” button as ‘y’ <3> Select the “USB OTG FOTG2XX(Faraday) support” button as ‘y’

FIC8120 Programming Guide www.faraday-tech.com

98

<4> Select the “Support for USB gadgets” button

<5> Select the “Support for USB Gadgets” as ‘y’ <6> Select the “USB Peripheral Controller Driver” to ‘Faraday-FOTG2XX’ <7> Select the “File-backed Storage Gadget” as ‘y’, current peripheral mode only provides mass storage class

FIC8120 Programming Guide www.faraday-tech.com

99

<8> Build a ram disk image, named the ramdisk as “ram.img”, and copy the ramdisk into your Linux-image’s ramdisk <9> After system have bootup, enter command “FOTG_ap e” to enable peripheral mode function 3.12.3.2 Built-in FOTG200 with Host only mode <1> Select the “USB support” button

<2> Select the “Support for USB” button as ‘y’ <3> Select the “USB OTG FOTG2XX(Faraday) support” button as ‘y’

FIC8120 Programming Guide www.faraday-tech.com

100

<4> Select the “Support for USB gadgets” button

<5> Select the “Support for USB Gadgets” as ‘n’

FIC8120 Programming Guide www.faraday-tech.com

101

3.12.3.3 Built-in FOTG200 with Peripheral mode only <1> Select the “USB support” button

<2> Select the “Support for USB” button as ‘y’ <3> Select the “USB OTG FOTG2XX(Faraday) support” button as ‘n’

FIC8120 Programming Guide www.faraday-tech.com

102

<4> Select the “Support for USB gadgets” button

<5> Select the “Support for USB Gadgets” as ‘y’ <6> Select the “USB Peripheral Controller Driver” to ‘Faraday-FOTG2XX’ <7> Select the “File-backed Storage Gadget” as ‘y’, current peripheral mode only provides mass storage class

FIC8120 Programming Guide www.faraday-tech.com

103

<8> Build a ram disk image, named the ramdisk as “ram.img”, and copy the ramdisk into your Linux-image’s ramdisk <9> After system have bootup, enter command “FOTG_ap e” to enable peripheral mode function 3.12.3.4 FOTG200 modulation with Peripheral mode only <1> Select the “USB support” button

<2> Select the “Support for USB” button as ‘y’ <3> Select the “USB OTG FOTG2XX(Faraday) support” button as ‘n’

FIC8120 Programming Guide www.faraday-tech.com

104

<4> Select the “Support for USB gadgets” button

<5> Select the “Support for USB Gadgets” as ‘m’ <6> Select the “USB Peripheral Controller Driver” to ‘Faraday-FOTG2XX’ <7> Select the “File-backed Storage Gadget” as ‘m’, current peripheral mode only provides mass storage class

FIC8120 Programming Guide www.faraday-tech.com

105

<8> Build a ram disk image, named the ramdisk as “ram.img”, and copy the ramdisk into your Linux-image’s ramdisk <9> Copy gadget and mass storage driver modules into your Linux-image’s ramdisk <10> After system have bootup, insert driver modules first, then enter command “FOTG_ap e” to enable peripheral mode function

3.12.4 FOTG200 Host mode support Mass Storage <1> Select the “USB support” button

<2> Select the “Support for USB” button as ‘y’ <3> Select the “USB OTG FOTG2XX(Faraday) support” button as ‘y’

FIC8120 Programming Guide www.faraday-tech.com

106

<4> Select the “USB Mass Storage support” button as ‘y’ <5> Select the “USB Mass Storage verbose debug” button as ‘y’

<6> Change to Main Menu, select the “SCSI support” button

FIC8120 Programming Guide www.faraday-tech.com

107

<7> Select the “SCSI support” button as ‘y’ <8> Select the “SCSI disk support” button as ‘y’ <9> Keep the default value in “Maximum number of SCSI disks that can be loaded as modules” filed

<10> After system have bootup, plug the mass storage device in, the message shown which device node has inserted <11> If “File systems”Æ”/dev file system support” selected as ‘y’, the following information represents one partition is existing in scsi disk ‘sda’ and named as ‘sda1’

FIC8120 Programming Guide www.faraday-tech.com

108

<12> If “File systems”Æ”/dev file system support” selected as ‘n’, the following information represents one partition is existing in scsi disk ‘sda’ and named as ‘sda1’

FIC8120 Programming Guide www.faraday-tech.com

109

3.12.5 FOTG200 Peripheral mode execution <1> Remind that current FOTG200 peripheral mode only provides mass storage class <2> Enable FOTG200 peripheral mode first, the steps already describe as above <3> After plug EVB to PC via usb cable, the message will display as following

FIC8120 Programming Guide www.faraday-tech.com

110

<4> One new removable drive is appeared in My Computer folder

<5> Try to add some files to this new drive <6> Remove EVB from PC, try to mount ‘ram.img’ in linux and browse the contents

FIC8120 Programming Guide www.faraday-tech.com

111

3.12.6 Reference ● Faraday USB2.0 On-The-Go Controller Datasheet ● Linux Device Drivers, 2nd Edition Available at website http://www.oreilly.com/catalog/linuxdrive3/

3.13 Output OSD Play Application

3.13.1 Introduction The following sections describes the execution of Faraday OSD Play.

FIC8120 Programming Guide www.faraday-tech.com

112

3.13.2 Configuration Setting

68.

Figure 3-51.

Kernel Configuration for GPIO Driver

Before running this program, you must enable both Faraday GPIO and LCD driver.

3.13.3 Work Flow OSD Play Command Play => osdplay “directory” such as /mnt/sddisk Exit => Ctrl + C Control method => GPIO button K1 is Enable / Disable OSD function K2 is select which item K3 run this function

FIC8120 Programming Guide www.faraday-tech.com

113

Result (Select item 1) ====================================================

Faraday MPEG Audio Decoder (FMAD) V1.2

==================================================== 00:09, Layer 3, 128 kbps, 44100 Hz, stereo, Normal kill 28 thread play item 1 Run fwma /mnt/sddisk/1.wma

(Select item 2) =====================================================

Faraday Windows Media Audio V8 Decoder (FWMA8) V0.1

===================================================== kill 29 threadreo, 64 kbps, No DRM, 00 : 00 : 02 play item 2 Run faac /mnt/sddisk/1.m4a

===================================================== Faraday MPEG-4 AAC Decoder (FAAC-MP4) V1.0 Demo Version ===================================================== /mnt/sddisk/1.m4a file info:

LC AAC 199.427 secs, 2 ch, 44100 Hz

(Select item 0) kill 30 thread, 138 kbps, 00:00:04 play item 0 Run fmad /mnt/sddisk/1.mp3

====================================================

Faraday MPEG Audio Decoder (FMAD) V1.2

==================================================== 01:20, Layer 3, 128 kbps, 44100 Hz, stereo, Normal

Demo version limitation: •

MP3 file name must be “1.mp3”

FIC8120 Programming Guide www.faraday-tech.com

114



M4A file name must be “1.m4a”



WMA file name must be “1.wma”

3.14 MTD Driver

3.14.1 Introduction Described below illustrates the execution of Faraday MTD function

3.14.2 Configuration Setting

69.

Figure 3-52.

Kernel Configuration for MTD Driver

FIC8120 Programming Guide www.faraday-tech.com

115

70.

Figure 3-53.

Kernel Configuration for MTD Memory Driver

71.

Figure 3-54.

Kernel Configuration for MTD Mapping Driver

FIC8120 Programming Guide www.faraday-tech.com

116

72.

Figure 3-55.

Kernel Configuration for MTD JFFS2 File System

3.14.3 Work Flow Mount MTD Command •

mkdir /mnt/mtd



mount -t jffs2 /dev/mtdblock1 /mnt/mtd

Read/write enabled. When the read/write command is completed, the ramdisk must be un-mounted. •

umount /mnt/mtd

The default MTD ramdisk size is set at 1MB. If you were to boot from EEPROM, then you must erase your address at 0x80500000 and size 0x100000 before you use MTD. If you were to boot from Flash, then you must erase your address at 0x80100000.

3.15 Input OSD Function

3.15.1 Introduction Described below is the execution of Faraday Input OSD function.

FIC8120 Programming Guide www.faraday-tech.com

117

3.15.2 Configuration Setting

73.

Figure 3-56.

Kernel Configuration for Input OSD Driver

When you run ffmpeg function, input video and input OSD character will be merged together and put into capture memory. Note: Only support for D version FIC8120 later

3.16 Color transform Application

3.16.1 Introduction Described below is the method to use Color transform from RGB to YUV function. When you select LCD YUV mode, if your video output GUI is RGB format, you must transfer RGB to YUV first. Now we can use this function to transfer RGB to YUV, you only have to select a region for MP4 YUV output, and other region we will be color transform from RGB to YUV.

3.16.2 Work Flow You can update arm-linux-2.4.19\drivers\video\flcd.c file to enable this define and see the result,

FIC8120 Programming Guide www.faraday-tech.com

118



#ifdef CONFIG_TEST_COLORTRANS //test half RGB and YUV penguin

• *(volatile unsigned int *)(CPE_PMU_VA_BASE + 0x28) = (*(volatile unsigned int *)(CPE_PMU_VA_BASE + 0x28)) | (1 << 8); • •

printk("Test color transform function data clampping (100,0~420,240)RGB -> YCbCr422\n");



*(unsigned int *)(CPE_COLORTRANS_VA_BASE + 0x4) = (100/4)-1;



*(unsigned int *)(CPE_COLORTRANS_VA_BASE + 0x8) = 0;



*(unsigned int *)(CPE_COLORTRANS_VA_BASE + 0xc) = (420/4)-1;



*(unsigned int *)(CPE_COLORTRANS_VA_BASE + 0x10) = (240/2)-1;

• *(unsigned int *)(CPE_COLORTRANS_VA_BASE + 0x0) = (*(unsigned int *)(CPE_COLORTRANS_VA_BASE + 0x0)) | 0x13; •

#endif



#ifdef CONFIG_D_VERSION

//For D version LCD data clampping

• • *(volatile unsigned int *)(CPE_PMU_VA_BASE + 0x28) = (*(volatile unsigned int *)(CPE_PMU_VA_BASE + 0x28)) | (1 << 8); • •

*(unsigned int *)(CPE_COLORTRANS_VA_BASE + 0x0) = 0x2; #endif

Note: LCD driver must set YUV422 mode (driver/video/flcd.c must enable #define mode_422) Only support for D version FIC8120 later

3.17 RTC Function

3.17.1 Introduction Described below is the method which use Faraday RTC IP or S35390A chip to do RTC function. Typically, a Linux RTC application (such as hwclock or clock) may access RTC through the following two interfaces: /proc/driver/rtc or IOCTL to facilitate time setting and reading. Furthermore, Linux RTC drivers support the use of hardware RTC alarm through standard synchronous blocking I/O interfaces such as read(), or synchronous non-blocking I/O (select()). Though there’s no standard interface for RTC drivers, most Linux RTC drivers try to mimic the behavior of standard PC RTC driver.

FIC8120 Programming Guide www.faraday-tech.com

119

3.17.2 Configuration Setting

刪除: 57

74.

Figure 3-57.

Kernel Configuration for RTC Driver

/proc/driver/rtc interface An RTC device can report its status from /proc file system. The de facto path of the virtual file representing RTC is /proc/driver/rtc. To use it, one can simply use the “cat” command, just as follow:

# cat /proc/driver/rtc rtc_time

: 00:00:59

rtc_date

: 1970-01-01

rtc_epoch

: 1970

alrm_time

: 08:03:00

alrm_date

: N/A for CPE120

alarm_IRQ

: no

# /ioctl interface RTC driver supports the basic functions of RTC: the set and read of RTC time, and you must check if /dev directory must has rtc derive. If not, please mknod rtc c 10 135

Function

Description

FIC8120 Programming Guide www.faraday-tech.com

120

RTC_RD_TIME

Read RTC Time

RTC_SET_TIME

Set RTC Time

AP example:

3.17.3 Source code This Section only list the related source codes of RTC driver.

刪除: 22 Table 3-22.

Source Code Directory Structure

Directory path: drivers/ Directory char

Description All source codes of character device drivers are put in this directory. 刪除: 23

Table 3-23.

Source File List

Directory path: drivers/char/ cpe-rtc.c

Faraday RTC driver implementation.

S35390-rtc.c

S35390 chip RTC driver implementation.

3.18 WatchDog Function

3.18.1 Introduction

FIC8120 Programming Guide www.faraday-tech.com

121

z Described below is the method which use Faraday WDT IP to automatically reset system when the system is not responding. Usually it is equipped with a down-counting counter, with user-supplied reload values. When the counter goes zero, most watchdog timer will issue a reset signal to the system. Hence the system should periodically reload the counter value to prevent the reset of it. If the system is unable to respond, or forms into a deadlock, or get trapped into a infinite loop etc. the watchdog timer can then automatically reset the system (i.e. put the system back to a known state). If you want to use AP to run IOCTL, you must create character device file /dev/wdt with (major, minor)=(10, 130)

FIC8120 Programming Guide www.faraday-tech.com

122

3.18.2 Configuration Setting

刪除: 58

75.

Figure 3-58.

Kernel Configuration for RTC Driver

3.18.3 Source code This Section only list the related source codes of WDT driver. 刪除: 24 Table 3-24.

Source Code Directory Structure

Directory path: drivers/ Directory char

Description All source codes of character device drivers are put in this directory. 刪除: 25

Table 3-25.

Source File List

Directory path: drivers/char/ cpe-wdt.c

Faraday WDT driver implementation.

FIC8120 Programming Guide www.faraday-tech.com

123

3.19 I2C Function

3.19.1 Introduction When we talk about I2C, we use the following terms: Bus

-> Algorithm Adapter

Device -> Driver Client An Algorithm driver contains general code that can be used for a whole class of I2C adapters. Each specific adapter driver depends on one algorithm driver. A Driver contains the general code to access some type of device. Each detected device gets its own data in the Client structure. Usually, Driver and Client are more closely integrated than Algorithm and Adapter. Included Bus Drivers ================ Base modules -----------i2c-core.c: The basic I2C code, including the /proc interface i2c-proc.c: The /proc interface for device (client) drivers Algorithm drivers ----------------i2c-algo-faraday.c:

An algorithm for I2C device in Faraday processors

Adapter drivers --------------i2c-faraday-adapter.c:

(uses i2c-algo-faraday)

So we design a algorithm driver(i2c-algo-faraday.c) as bus driver to access hardware device via I2C-bus. In i2c-algo-faraday.c , it mainly provides two export subroutines (i2c_sendbytes, i2c_readbytes) for accessing by device driver or programs on user space. The main advantage with the architecture design contributes users to implement device driver

FIC8120 Programming Guide www.faraday-tech.com

124

with hardware independent. It is not necessary for driver programmers to care how to implement between device driver and bus driver. As long as based on faraday bus driver, programmer will implement the device driver easily. That will speed up development and simplify the complexity to develop I2C device driver on faraday board.

FIC8120 Programming Guide www.faraday-tech.com

125

3.19.2 Source code Before developing device driver, you should make sure the necessary module is built in kernel firstly. Relative files in linux kernel are in the following directory : i2c-algo-faraday.c : kernelsource_root/drivers/i2c/ i2c-core.c

: kernelsource_root/drivers/i2c/

i2c-faraday-adap.c : kernelsource_root/drivers/i2c/ Makefile

: replace the original kernelsource_root/drivers/i2c/Makefile

Config.in

: replace the original kernelsource_root/drivers/i2c/Config.in

i2c-algo-faraday.h : kernelsource_root/include/linux/ i2c-id.h

: replace the original kernelsource_root/include/linux/i2c-id.h

At the same time, remember to disable the file arch/arm/mach-cpe/Makefile like the following , avoiding to redefine problems between i2c-eeprom.c and original eeprom.c. #obj-$(CONFIG_FIC8120_PLATFORM)

+=eeprom.o

While executing the command “make menuconfig” under linux kernel-2.4.19, there are some necessary options we need to enable like the following : -> Character device-> I2C support <*>I2C support <*>I2C Faraday interfaces <*>

Faraday I2C device driver on FIC8120

<*>I2C /proc interface(required for hardware sensors)

3.19.3 Access I2C-bus function in kernel mode With installing of I2C faraday bus driver, it provides two export subroutines below for device driver :

int faraday_i2c_write(unsigned int i_dev_addr ,unsigned int i_dev_offset, unsigned char *buf, unsigned int size, int clockdiv) i_dev_addr : device address to write i_dev_offset : offset to write

FIC8120 Programming Guide www.faraday-tech.com

126

buf : data to write size : data length to write clockdiv : set i2c_bus speed( 0 means don’t’ care and use default i2c_bus) default is 45 k

int faraday_i2c_read(unsigned int i_dev_addr, unsigned int i_dev_offset, unsigned char *buf, unsigned int size, int clockdiv) i_dev_addr : device address to read i_dev_offset : offset to read buf : data to transmit size : data length to transmit clockdiv : set i2c_bus speed( 0 means don’t care and use default i2c_bus) default is 45 k

FIC8120 Programming Guide www.faraday-tech.com

127

3.19.4 Access I2C function in user mode We design a common interface(/dev/i2c-0) for accessing i2c device from userspace . We provide a sample in C code like the following : PS : I2C read and write will be determined by device address. if the last bit of device address is 1, the system will recognize to read the byte. So you won’t specify the i2c action(read or write). int file; int adapter_nr = 0; /* probably dynamically determined */ char filename[20]; static char buf[10]; struct i2c_faraday_msg i2c_ap ;

//structure defined in kernel/include/linux/i2c-algo-faraday.h

sprintf(filename,"/dev/i2c-%d",adapter_nr); if ((file = open(filename,O_RDWR)) < 0) { /* ERROR HANDLING; you can check errno to see what went wrong */ exit(1); } i2c_ap.addr = EEPROM_ID_WRITE; i2c_ap.waddr = addr;

// device offset to write

i2c_ap.len = 6 ; buf[0]=0x10; buf[1]=0x20; buf[2]=0x30; buf[3]=0x40; buf[4]=0x50; buf[5]=0x60; 格式化: 德文 (德國)

i2c_ap.clockdiv = 0 ;

// I2C bus clock(Unit :K) e.g: 230 means 230 K // if you don't know which value to fill, please fill "0" , system will use the default reason speed for i2c bus

FIC8120 Programming Guide www.faraday-tech.com

128

i2c_ap.buf = &buf[0] ; if (ioctl(fd,I2C_RDWR,&i2c_ap) < 0) { printf("Error in ioctl I2C_SLAVE(%2x)\n",I2C_SLAVE); return -1; } printf("i2c write byte successfully!\n");

I2C_RDWR : command , defined in i2c.h

FIC8120 Programming Guide www.faraday-tech.com

129

Appendix

FIC8120 Programming Guide www.faraday-tech.com

130

Appendix A: Hardware Assignment

A.1: FIC8120 Board I/O Address Mapping and Interrupt Assignment 刪除: Table A-1

The FA526 offers FIQ and IRQ interrupt types as provided by ARM architecture. Table A-1 describes the interrupt number and Table A-2 describes the I/O address assignment for each component. The definition is located in /include/asm/arch/cpe/FIC8120.h.

Table A-1.

Interrupt Number Assignment

IRQ Resource

Interrupt Name

FIQ Resource

Interrupt Name



31



T_ext_int[3]



31



T_ext_int[3]



30



T_ext_int[2]



30



T_ext_int[2]



29



T_ext_int[1]



29



T_ext_int[1]



28



T_ext_int[0]



28



T_ext_int[0]



27



ide_intr



27



ide_intr



26



dma_intr



26



dma_intr



25



uart4_intr



25



uart4_intr



24



brg_intr



24



brg_intr



23



uart3_intr



23



uart3_intr



22



cap_intr



22



cap_intr



21



mcp_intr



21



mcp_intr



20



LC_MERRINTR



20



LC_MERRINTR



19



tm1_intr



19



tm1_intr



18



rtc_sec



18



rtc_sec



17



rtc_alarm



17



rtc_alarm



16



wd_intr



16



wd_intr



15



tm3_intr



15



tm3_intr



14



tm2_intr



14



tm2_intr



13



gpio_intr



13



pci_int



12



uart2_intr



12



uart2_intr



11



LC_FURINTR



11



LC_FURINTR



10



uart1_intr



10



uart1_intr



9



LC_VSTATUSINTR



9



LC_VSTATUSINTR



8



pmus_fiq



8



pmus_fiq



7



LC_BAUPDINTR



7



LC_BAUPDINTR



6



mpca_int2



6



mpca_int5



5



sdc_intr



5



otg_int



4



mpca_int1



4



mpca_int4

FIC8120 Programming Guide www.faraday-tech.com

131

IRQ Resource

Interrupt Name

FIQ Resource

Interrupt Name



3



i2c_intr



3



mac_int



2



ssp_intr1



2



ssp_intr1



1



mpca_int0



1



mpca_int3



0



lcdc_intr



0



lcdc_intr

Table A-2.

I/O Address Assignment

By Address Sorting AHB Slave ID

Base

Size



AHB_SLAVE_4





0000_0000



256M



AHB_SLAVE_6

• SDRAM controller (memory, use SDRAM channel 2)



1000_0000



2G



AHB_SLAVE_0



AHB controller (arbiter/decoder)



9010_0000



1M



AHB_SLAVE_3



SMC (register)



9020_0000



1M



AHB_SLAVE_5



SDRAM controller (register)



9030_0000



1M



AHB_SLAVE_14



MPCA



9040_0000



1M



AHB_SLAVE_1



AHB-to-APB bridge (register)



9050_0000



1M



AHB_SLAVE_9



LCD controller



9060_0000



1M



AHB_SLAVE_8



FTMCP100



9070_0000



1M



AHB_SLAVE_11



ColorTransfer



9080_0000



1M



AHB_SLAVE_12



MAC



9090_0000



1M



AHB_SLAVE_13



InputOSD



90a0_0000



1M



AHB_SLAVE_10



not-used



90b0_0000



1M



AHB_SLAVE_15



DMA’s slave



90c0_0000



1M



AHB_SLAVE_16



PCI (register)



90e0_0000



2M



AHB_SLAVE_28



USB 2.0 OTG



9130_0000



1M



AHB_SLAVE_29



IDE



9140_0000



1M



AHB_SLAVE_17



MPCA



9150_0000



1M



AHB_SLAVE_18



MPCA



9160_0000



1M



AHB_SLAVE_20



EBI



9230_0000



1M



AHB_SLAVE_7



Capture controller



9680_0000



1M



AHB_SLAVE_2



AHB-to-APB bridge (APB Device)



9800_0000



128M



AHB_SLAVE_21



PCI (memory)



a000_0000



256M

SMC (memory)

FIC8120 Programming Guide www.faraday-tech.com

132

By Address Sorting APB Slave ID

Base

Size



APB_SLAVE_16



PMU



9810_0000



1M



APB_SLAVE_3



UART 1



9820_0000



1M



APB_SLAVE_4



UART 2



9830_0000



1M



APB_SLAVE_17



TIMER



9840_0000



1M



APB_SLAVE_18



WDT



9850_0000



1M



APB_SLAVE_19



RTC



9860_0000



1M



APB_SLAVE_20



GPIO



9870_0000



1M



APB_SLAVE_21



INTC



9880_0000



1M



APB_SLAVE_11



UART 3



9890_0000



1M



APB_SLAVE_22



I2C



98a0_0000



1M



APB_SLAVE_2



SSP1 (I2S/AC97)



98b0_0000



1M



APB_SLAVE_5



SD card



98e0_0000



1M



APB_SLAVE_23



MPCA



9910_0000



1M



APB_SLAVE_24



MPCA



9920_0000



1M



APB_SLAVE_25



MPCA



9930_0000



1M



APB_SLAVE_8



UART 4



9960_0000



1M



APB_SLAVE_26



MPCA



9970_0000



1M



APB_SLAVE_27



MPCA



9980_0000



1M



APB_SLAVE_28



MPCA



9990_0000



1M

FIC8120 Programming Guide www.faraday-tech.com

133

Appendix B: Load Image to Target SDRAM You can load images to target SDRAM in three ways, as detailed in Sections B.1, B.2 and B.3.

B.1: Load Image to Target SDRAM by AXD You can use your AXD to load images to target SDRAM using JTAG interface. The procedure is as follows: •

Open AXD debugger.



Select “File->Load Memory From File”, then input the file name and address.



Press Open and finish.

B.2: Load Image to Target SDRAM by Ethernet You can use ARMBOOT to load images to target SDRAM using Ethernet interface. The procedure is as follows: •

Run ARMBOOT. (Please refer to Section 2.3 for this procedure.)



Set environment variables “serverip” and “ipaddr”. (Please refer to Section 2.3.) Assume TFTP server IP address is 192.168.52.188, and target IP address is 192.168.52.100. CPE> setenv serverip 192.168.52.188 CPE> setenv ipaddr 192.168.52.100



The example uses ARMBOOT command “tftp” to load images. Assuming the image name is “image.bin”, put it to the target SDRAM address 0x500000. CPE> tftp 0x500000 image.bin

B.3: Load Image to Target SDRAM by UART You can use ARMBOOT to load images to target SDRAM using UART interface. Assume you use “Hyper Terminal” to be your PC terminal program. “Hyper Terminal” setting is as follows: no-parity, data length = 8, stop bit = 1 and baud rate = 38400 bps. The procedure is as follows: •

Run ARMBOOT. (Please refer to Section 2.3 for the procedure.)



On Target site, use ARMBOOT command “loadb” to launch kermit transfer. CPE> loadb 0x500000 On PC site, select Transfer -> Send File from the menu on Hyper Terminal, and give the filename and select the protocol Kermit. Press Send and wait until the process is finished.

FIC8120 Programming Guide www.faraday-tech.com

134

Appendix C: Programming Flash The specified address mapped to flash is set to 0x80000000 by default. The physical memory mapping is as shown in the following figure.

0x0 128 MB SDRAM

0x80000000 16 MB Flash 0x81000000

76.

Figure C-1.

Physical Memory

FA526-Linux Distribution provides ARMBOOT for you to easily program your flash module. The types of flash module currently supported by ARMBOOT are as follows: SST39VF080 SST39VF016 MX29LV008B IntelE28F128 ARMBOOT provides some commands for flash programming. These commands are listed in the following table:

Table C-1.

Command List

Command

Description



flinfo



Show the flash information



cp.b [source] [destination] [size]



Copy the content of source to destination



erase [address 1] [address 2]



Erase flash from address 1 to address 2

You can use these commands to program the flash. For example, when you want to write image armboot.bin to flash, you may take the following actions: Example(must depend on your start address and size): •

Load image to specified address 0x1000000. (You can refer to Appendix B for the procedure.)



Erase flash size 256K from 0x80100000 to 0x80CFFFFF by using ARMBOOT command

FIC8120 Programming Guide www.faraday-tech.com

135

“erase”. CPE> erase 0x80100000 0x80CFFFFF •

Copy image from 0x1000000 to 0x80100000 with size 0x501000 by using command “cp.b”. CPE> cp.b 0x1000000 0x80100000 0x501000

FIC8120 Programming Guide www.faraday-tech.com

136

Appendix D: bootpImage Flow FA526-Linux provides bootpImage to run Linux kernel. The bootpImage comprises four components 刪除: Figure D-1

as depicted in Figure D-1 and listed below: •

Bootp Image: The code to copy “Decompressor” and “Compressed Kernel” to specified SDRAM position, and to copy “Ramdisk” to another SDRAM position.



Decompressor Image: The code in charge of decompressing “compressed kernel”.



Compressed Kernel Image: The image of “compressed kernel”.



Ramdisk Image: The file system image provided for Linux kernel.

Flash Area

Bootp

armboot

Decompressor

bootpImage

Compressed kernel

0x80200000 0x80240000

Ramdisk (minix)



77.

Figure D-1.

Bus 16 bit width bootpImage Components

When FA52x jumps to 0x80240000 and runs the bootpImage code, the software operations will be as follows: •

Bootp program copies Part A to 0x500000, Part B to 0x900000, and branches to 0x500000 刪除: Figure D-2

(that is, Decompressor). (See Figure D-2.)

0x80240000

Part A Part B

Bootp Decompressor Compressed Kernel Ramdisk (minix) Flash Area

0x500000 copy

Decompressor Compressed Kernel

0x900000 copy

Ramdisk (minix) SDRAM Area



78.

Figure D-2.

Bootp Procedure



Decompressor program unzips kernel to 0x8000 and branches to it.



Linux kernel starts running code at 0x8000. It loads ramdisk from 0x900000 during Linux boot

FIC8120 Programming Guide www.faraday-tech.com

137

time. •

Linux kernel booting done. You can see the shell prompt on your terminal.

FIC8120 Programming Guide www.faraday-tech.com

138

Appendix E: ramdisk Maintenance

E.1: Create a New ramdisk

刪除: 1

Use the program “dd” to create your ramdisk. Assume you want to create a 4 MB ramdisk image named “ramdisk.img”. The command will be as follows: # dd if=/dev/zero of=ramdisk.img bs=4096k count=1 After creating ramdisk.image, you have to format it with the specified file system. If the file system is EXT2, the command would be as follows: # mkfs.ext2 ramdisk.img If the file system is MINIX file system, the command would be as follows: # mkfs.minix ramdisk.img

E.2: Add/Remove Files from ramdisk Image In order to add/remove files from ramdisk image, you must mount the image to the specified directory first. The following example assumes that the mount point is /mnt/ramdisk. # gunzip ramdisk.tgz # mkdir /mnt/ramdisk # mount –o loop ramdisk.img /mnt/ramdisk You can use a command such as “cp” or “mv” to add or remove files from /mnt/ramdisk. After finishing the addition or removal, you have to do un-mount. # umount /mnt/ramdisk # gzip ramdisk After the specified ramdisk is ready, be sure to modify the file mkbootp.sh for the ramdisk.

FIC8120 Programming Guide www.faraday-tech.com

139

Related Documents

Fic8120 Linux Pg V0
November 2019 9
Objetosdeaprendizaje-v0
November 2019 32
Da1196h V0
May 2020 19
V0-1
December 2019 21
Pg
November 2019 55