|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 _- ]# G7 V) y$ R6 c! f3 \
#include <linux/init.h>
& |% D: t* \! z& u/ }0 g V1 f+ u#include <linux/module.h>
4 V* ^. C3 x7 l0 ~# O#include <linux/kernel.h>6 h# S+ D* U ?
#include <linux/types.h>; }, Q1 k) R4 M
#include <linux/gpio.h>; o3 ~. [+ J, r. \: o+ V
#include <linux/leds.h>/ o( K) t! o7 i
#include <linux/platform_device.h>% F4 J$ L" q/ A
. z# q5 L$ h0 J2 E) ~9 @2 z, h#include <asm/mach-types.h>5 }& R& n- f: N( a
#include <asm/mach/arch.h>2 I; u) e( m5 i: i, g+ |
#include <mach/da8xx.h>
% p5 V8 @/ U, e3 k& k; f q#include <mach/mux.h>
8 ^8 k6 s: ^( z$ o: Q0 G: n' c4 P
. j: k5 X \: E" ]4 p: j( d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) ]$ J0 B T' ]: y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' z4 t- z M3 e, ?/ x: a( \! I8 b
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 Q" J. r. a2 ]/ b/ N( k
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% I7 b$ ?1 D6 ]. }, H8 ]* ?; @2 w6 h7 H) j/ m# m
/* assign the tl som board LED-GPIOs*/3 H3 G2 }- L9 v0 q
static const short da850_evm_tl_user_led_pins[] = {
8 T$ x/ \' f3 r% P. I /* These pins are definition at <mach/mux.h> file */4 v( U! T Z! f, n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 E! S: X4 p* L+ K5 }7 |
-1
2 H0 i- t3 w1 R- x8 o};
Q1 k% [9 F2 m. r) @5 |
! _7 }3 f c9 }0 astatic struct gpio_led da850_evm_tl_leds[] = {; J) a; b* Z, V7 I
{
5 ?' p; a | g* q4 B8 ^ .active_low = 0,
8 f' Q# [* d& L& P: \ .gpio = DA850_USER_LED0,1 V3 h' e) m R+ X z# e# W
.name = "user_led0",! C) I. D9 D, F
.default_trigger = "default-on",+ i) y9 K' U9 y6 Q+ D: Q
},& I' u% [0 ? c0 G1 e
{
9 G6 z2 y. z3 M .active_low = 0,
: t4 Z( u; p7 C! J1 t5 b .gpio = DA850_USER_LED1, x! K$ Y$ x0 o
.name = "user_led1",
0 v' W* n0 ^) Q# z( P/ _$ b/ V. ` .default_trigger = "default-on",
! D2 T; y- f! L# r6 V& z: V3 V9 w },
5 k0 f: X7 @; c' I- y p" Q5 j {
5 J' w1 W3 J* K. O .active_low = 0,- X9 p& c0 u' T
.gpio = DA850_USER_LED2,% q, a; I/ j6 }/ F
.name = "user_led2",7 @1 u% Y/ J% h* ^
.default_trigger = "default-on",
- Y" [$ Z" I$ p3 C9 S/ n! Q' |* U; ? },7 C& {6 [- z( C/ l) D
{8 _# A+ I' _' n, W& a! Z d& A7 f
.active_low = 0,
y4 w! v8 F( G8 ]8 m& v .gpio = DA850_USER_LED3,
5 a# r& n( i% L4 R& ?. h .name = "user_led3",6 Y8 z J: J3 f0 Z) [- K" A
.default_trigger = "default-on",
$ m, Y, K9 `" T },
+ h0 z; S3 p3 C+ k};
: b/ \4 {2 o Y
, K, `; g) z P3 f; ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* ^6 L7 c1 |$ z; f' Z& Z .leds = da850_evm_tl_leds,
& q( o/ R0 K9 D5 P$ A7 g0 }5 K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, Z1 A+ @7 r1 N! j% a7 |, q};
2 t, I' o; O/ `& [/ P m D! X& V1 x* P
static void led_dev_release(struct device *dev)
& c+ D/ N& @. D A" V9 f" b q( u6 P% ?{9 x, q6 {+ q2 ~! [/ Z
};
) w; k; [8 s1 k, _; Z
0 T1 a! b1 K9 l1 Wstatic struct platform_device da850_evm_tl_leds_device = {
- R) s! X/ X( O9 c) Z- I v3 ` .name = "leds-gpio",: _( k; b0 {6 c; R+ r
.id = 1,
+ m+ g0 o( v# @8 @ .dev = {
' N9 r7 G9 l# x+ b .platform_data = &da850_evm_tl_leds_pdata,2 M7 T: @5 d5 t9 `; q
.release = led_dev_release,) o* P( h7 B1 g8 N( ^; u
}
3 N3 H5 u# Q" \8 l1 z5 f};# |& e$ }* a2 q8 \. D+ }
3 d( ?) K. W7 ]: |/ k
static int __init led_platform_init(void)
5 k" e1 q1 S% c1 T{
( I+ O3 ^# K$ a8 B5 F int ret;
) q+ X! n" d5 A3 ^+ p) n% ~% r#if 0
" h" d* [; T& I: j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; R- a" g4 `. z0 ^
if (ret)
1 j% v- m4 M- e, a pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ Q' e& p8 ]3 c "%d\n", ret);" M# V! S6 X8 W# D9 F5 {" Q* f
#endif- B! Y# P: @$ N4 Q8 X
ret = platform_device_register(&da850_evm_tl_leds_device);: R/ r3 D6 {9 E& K9 o, g. U
if (ret)
! y, C+ I) l7 e* E: S pr_warning("Could not register som GPIO expander LEDS");9 S8 d6 B! d- l+ \' H: z, U
else8 ], V- }4 ~3 g% w! q( j5 g
printk(KERN_INFO "LED register sucessful!\n");
; u+ l ~5 [, |( B. \+ e
+ X {. f# q4 v return ret;
0 J" x5 {' u# l8 w}3 P7 J) B6 A/ W- \7 I/ V3 y7 f
$ C: w" U' Y$ B/ X5 N$ \static void __exit led_platform_exit(void)# s7 U& U, K' I$ |: Y' a7 j% ]7 k
{
: `( [6 b) J: h1 f0 \ platform_device_unregister(&da850_evm_tl_leds_device);, d' J$ n' D. @% A/ G& ~- X4 j6 H* F
! l* v9 l2 L9 h3 B' q7 @- j& e printk(KERN_INFO "LED unregister!\n");
/ E, u2 W$ U1 t/ N+ q5 d! o4 P}
; }# a/ L$ t3 V( \0 f
5 [4 u4 _. I4 [* Y9 O8 z% a) Y L' Bmodule_init(led_platform_init);
" S7 s- y1 O- T* h, X/ Z* umodule_exit(led_platform_exit);
7 M. C- T. u5 d% u }. K' ?5 D
: N- Y8 d1 x/ _MODULE_DESCRIPTION("Led platform driver");
0 O7 l/ }' m; k. rMODULE_AUTHOR("Tronlong");
5 Q) N* Q& A$ g6 R8 i. WMODULE_LICENSE("GPL");
$ z% D, f! ^& `+ f, e. f2 V
m+ a' x# t% T" {6 |7 W! W |
|