|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 g9 F \. @/ ]1 _! ]#include <linux/init.h>- z1 V& g, ]; I5 J9 O6 q
#include <linux/module.h>
- k! E( L+ U/ X' @2 \! E" T#include <linux/kernel.h>) q9 h+ A% V$ B4 B1 p$ U
#include <linux/types.h>, n* [1 {" b# W; R; d$ u' Z
#include <linux/gpio.h>
! P9 u T4 g7 G$ R#include <linux/leds.h>3 O: |9 `& V( C ^6 }1 @
#include <linux/platform_device.h># B8 V j6 B& E% q3 t4 K/ l
4 I6 x6 f& N+ W' c1 C" j' G#include <asm/mach-types.h>( x f* N7 B( ]8 k+ T* X. D6 v
#include <asm/mach/arch.h>, O* x+ B/ B$ |& H5 K7 U% ~
#include <mach/da8xx.h>
3 y1 Q8 w: ]' J% V* \% I#include <mach/mux.h>
6 J* i+ `+ v4 z' L: Y0 }6 n4 A Z+ z: Z) P/ p% p! q. ^0 G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) o7 G7 e& V/ M8 T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# G% x$ g- w# y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 Z5 g1 e# K" E#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! G+ V/ @( j N3 E# q; r8 }# L. g( v( E9 Z6 x7 c3 O& f
/* assign the tl som board LED-GPIOs*/
4 \! e9 ?& g% X( r: s6 C) U# G' Xstatic const short da850_evm_tl_user_led_pins[] = {
' W% e" q; C( S2 x /* These pins are definition at <mach/mux.h> file */: I& _5 V2 G: d/ o5 Q: J$ R( [. X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# s4 T! q/ {) U x# [; x- f -1, O' U+ [' k% l% U( x) D
};
8 B- J- T% X2 Z& X! m) s2 P4 @7 L% {: Q9 L' i$ L( Q5 a/ c7 Z
static struct gpio_led da850_evm_tl_leds[] = {( t7 h, J1 B8 ~* U R( e7 l( x9 _
{
( l* M( `" b0 e; h .active_low = 0,
2 W) R% |4 ~0 O, w2 s. d7 Z .gpio = DA850_USER_LED0,
/ z' f/ d# a$ i0 G .name = "user_led0"," [0 {0 c% Z/ j9 K2 v6 e% Q
.default_trigger = "default-on",
, Z6 v$ X+ a! |. ^2 p0 R },2 X/ b: m2 q9 y
{
5 G& f- |9 Z8 E3 k .active_low = 0,- A$ J# `# H: y
.gpio = DA850_USER_LED1,% s! W. O1 Z, i( D
.name = "user_led1",
# z$ O. c- Z0 l/ u2 i4 a! C .default_trigger = "default-on", v- v3 k% f5 K6 t
},9 v. F# T2 O4 H8 x/ _, F% @! N( Y
{
) f% A2 |; l- B9 K- d( e4 T+ v. P .active_low = 0,
' a( b* s7 H7 h+ E4 O* `# B .gpio = DA850_USER_LED2,: f! F/ _9 ?+ @
.name = "user_led2",
2 N, v ^2 h$ c .default_trigger = "default-on",2 j- b6 `* _: n; R/ j+ }( L$ S
},) T. Z; _5 o" U2 p4 l
{
# G6 Z+ K" l# z3 E! i .active_low = 0,( z, J0 ?# t' v) F, R
.gpio = DA850_USER_LED3,
6 d7 l( o0 u& O .name = "user_led3",6 u g8 d5 a, F5 Z
.default_trigger = "default-on",
2 n, i5 ?4 [( ]* e0 |+ A' s },
) X% Q6 p( ?$ t};8 b9 |7 v* l) M4 O" @
! ~1 v+ ?2 a @2 N3 C, @# [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. q2 L# j( E M5 b) t' P: G .leds = da850_evm_tl_leds,+ o6 a k" y1 S' b2 K1 s A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),# V% q( X* W5 t9 p
};
& j+ m* h/ ^) Y4 a7 |9 P$ E! `6 B8 K- M6 G& o J( h' L& p9 _
static void led_dev_release(struct device *dev)' U$ Z3 c7 H1 f7 z6 |
{
9 t. Y& l4 N6 s8 P5 d( L9 e+ V( Z};' T; l3 m5 T& x7 E5 B. R/ m
' y* z1 w- t6 G) ^
static struct platform_device da850_evm_tl_leds_device = {4 i# S3 ~% X9 A- M) i1 T
.name = "leds-gpio",
- r5 O$ ~$ ~4 J9 N/ X2 Y! z: n; H .id = 1,
( {, k& V) V# I# n .dev = {
( B% Z0 b4 Z7 y' M0 i .platform_data = &da850_evm_tl_leds_pdata,
9 L5 W$ I& O; n' g# i' e3 l .release = led_dev_release,: o! N" E4 z& g2 v
}
( e6 O( ~; }; Z0 G};% V7 j, X6 B) `* v) ^( K3 t+ {
/ x2 N! c$ U) ]2 y$ C
static int __init led_platform_init(void)
- _* l% J9 h1 D1 R9 ~; B; Q{
9 w0 Y+ O) y& Z* o# |7 T. @! \ int ret;
" Z1 I! i7 {* Y3 s: A9 k2 k#if 0
# d- W2 M: O- B( d( N$ F4 A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* Y; _' N4 S( v
if (ret)% Z5 E+ ~/ E; R# O t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
p9 ~) V! i" H0 h8 j' D "%d\n", ret);
8 I0 i6 F5 d9 w2 T* p2 `7 B#endif; Z( i0 H4 {- Q0 s/ a; o8 E7 b) z
ret = platform_device_register(&da850_evm_tl_leds_device);! S8 j) \" P: t2 J/ M$ j
if (ret)
! u6 Y& L. ?' o+ w pr_warning("Could not register som GPIO expander LEDS");
! r, b9 X1 [' C& Z else% X! ?( Y+ C% C$ {) G
printk(KERN_INFO "LED register sucessful!\n");) s) v) g* f {8 W$ u0 A% C! k
9 K3 n3 A% Q! B3 y3 G: U: }' v2 J return ret;
1 @: V5 y: Z1 q, e2 h: [}. l5 {9 t, f( \. s
5 I4 w+ ?8 T- o3 F
static void __exit led_platform_exit(void)
X2 ]& E$ j" ^) L& {* w+ F' ~{
9 N4 N/ j1 W9 N* [& E; X platform_device_unregister(&da850_evm_tl_leds_device);
$ P. Q* |' P4 s: a" D, F5 V
- l0 E4 ^: @8 R/ N5 ? printk(KERN_INFO "LED unregister!\n");2 W; I8 `1 s- q R7 @) f5 E, \% f+ ^
}
$ S" b/ N! i* {' g# B) p; c3 {: v) d, n$ C
module_init(led_platform_init);
" j' e; B8 n9 Zmodule_exit(led_platform_exit);
, [& {3 q) ?# S; p( M
; i7 B9 i! m! C- n0 l& w/ k4 pMODULE_DESCRIPTION("Led platform driver");
9 L$ ^2 R; f: h" J4 LMODULE_AUTHOR("Tronlong");
/ f; U- `! T( K* o4 g. S7 yMODULE_LICENSE("GPL");
/ f% G, U+ e" [0 t$ J7 z
% f' k5 b1 i3 R |
|