|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& V7 s# n) |# ^0 J- _7 `+ w6 R6 T
#include <linux/init.h>$ L9 \3 q! ^, Y t# U! f. }. z
#include <linux/module.h>1 o; n) [* L, E
#include <linux/kernel.h>
( q8 o: E5 {! ~4 l! W# w#include <linux/types.h>* p8 `0 J% c% b, [
#include <linux/gpio.h>
# ~# i1 w( k; O* H$ s; B" J. @#include <linux/leds.h>4 x! I, o( {4 S3 o
#include <linux/platform_device.h>& D$ ]: Q; F; @( S
4 e- ~; v! m# R
#include <asm/mach-types.h>) g/ M( N0 ]' l* m$ Y
#include <asm/mach/arch.h>
- d6 V2 q8 I( `#include <mach/da8xx.h>" j5 {. R+ [9 g3 d
#include <mach/mux.h>
( Z( K$ a; t l& H" g* ~: I4 E/ E/ y1 K9 ]$ W6 j( _" c2 O
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: B" d; i4 f9 B& Q& R; \: ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 g$ _/ a* E5 D) b, Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% N/ ]7 D2 b" {1 w, D7 C2 K4 Y9 r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ Y& H& R7 u! Y `* F# {4 B- t P2 D* d" @/ U# _
/* assign the tl som board LED-GPIOs*/
0 }; O+ L0 R' L Wstatic const short da850_evm_tl_user_led_pins[] = {
6 |$ K) h! ~- C /* These pins are definition at <mach/mux.h> file */% F1 [- Y D0 W" b- J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# C4 s: b( r, F3 \" S& L -1. f! N! w9 ~4 m& h1 U8 p
};" R5 M/ a3 X& k8 o9 H
5 ^- c% L2 A2 x( g* ^5 p: mstatic struct gpio_led da850_evm_tl_leds[] = {/ u+ W4 h( ^ O/ p) ]; ]0 v9 N
{
+ ]9 \, c& k$ b' D C .active_low = 0,( \, b! V5 f' A' {
.gpio = DA850_USER_LED0,6 t3 m/ K- @& D4 v ?9 F7 I; n0 T
.name = "user_led0",' U# C6 D- f# Y. V- ]0 ], _% x, U
.default_trigger = "default-on",
' H; ~/ V. ?6 y, s! c4 ` M$ P4 o },- D" s6 B8 D( z6 J
{- m ?0 X( r% z- \" o. k5 F1 r
.active_low = 0,3 j4 F$ w9 I% S9 c
.gpio = DA850_USER_LED1,
& @# W# X( R* R2 H: f% k .name = "user_led1",
% @! j( A0 e+ U2 M+ i; @; Y .default_trigger = "default-on",
# W: B* C, f( ]& C4 ~7 J: f },5 z) S4 _+ X7 t7 P5 _
{! E2 |9 `; j( D6 @9 P! @
.active_low = 0,
( O1 [ U% T: S8 V6 h% h! | .gpio = DA850_USER_LED2,; H. i6 b0 q. n, B$ }4 l# B @9 I
.name = "user_led2",
! Q' N9 S8 |6 t .default_trigger = "default-on",: U4 W2 }& p& m! r
},
5 f$ A& G0 p2 P* {$ A {, m1 N4 w$ f1 F; w! D) d8 c- B
.active_low = 0,
" Y0 c6 j$ f( P* W) T .gpio = DA850_USER_LED3,
* t+ L3 p [3 k H2 s0 n: @9 L .name = "user_led3",
' M) Z7 x$ x7 s' o: K4 ?) e .default_trigger = "default-on",
: ]0 ^, [; a l },
( b/ N. V5 L9 ~; M1 T* H};
6 b' s: z4 K, D0 o
4 I% R5 W* Y' X( Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 r, [) T m" O) y7 e6 e8 H- x
.leds = da850_evm_tl_leds,
, K! M7 k5 m- @$ E, I .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: }5 @9 B- o* B
};
0 a V5 D. }4 t2 N" ]6 I" x+ g" u% k
static void led_dev_release(struct device *dev)
3 z4 G: c9 f4 j6 k- h7 v: r{
~4 @- ?& i' q0 V};
w) {* y+ ~3 i8 }9 A) {7 R# l' p9 |5 r
static struct platform_device da850_evm_tl_leds_device = {
; p7 q7 f L0 B. } .name = "leds-gpio",, B6 s6 Z2 @9 B3 x
.id = 1,* T8 {; }" i/ c/ z
.dev = {- a9 O& c- p- d9 Q% i
.platform_data = &da850_evm_tl_leds_pdata,
# S6 P2 N" a& ?- ~: {5 w* N: I7 m- ? .release = led_dev_release,/ Q ^1 g z7 h7 a
}
8 T" p( a1 l/ r* m# x};
1 X: s! j1 p5 ^) C1 `! K4 [6 S3 u1 A3 H% d" Q
static int __init led_platform_init(void) k ]2 K: G: z8 i
{
2 z$ v C1 E: t6 U- k5 @ int ret;7 P# i; W2 Q* v. D7 r
#if 0
, M1 G0 J& J- p8 t' P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 f4 P8 Y8 a& o- M9 e) G if (ret)0 L, p+ ?% [0 _0 M9 O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 ]! T& ^/ ?# t+ K: ` "%d\n", ret);" Z" q' u5 G. n9 M6 l6 }
#endif
/ q6 L# X6 p/ H& ~; K ret = platform_device_register(&da850_evm_tl_leds_device);
+ [; j5 y9 k# E3 r7 }( J$ | J- {) ?- [ if (ret)
* U- @0 f' ?# f' W9 B pr_warning("Could not register som GPIO expander LEDS");
, [. n, @! ?5 O) ]2 j else
9 I" C; f# g# \3 e' C0 C printk(KERN_INFO "LED register sucessful!\n");
8 ~7 \; u4 w3 ^& F/ G6 V0 O' N# \7 p7 F+ |9 c3 `6 r C
return ret;
! I$ f' k! o2 ~, V- o* e: v}
$ Y" ?0 j' I1 C0 L- d* ^
0 l$ r) M2 A5 H) ^6 c+ e' sstatic void __exit led_platform_exit(void)
, W W: H5 ~ Q7 y5 v* H: @8 Y{
& A0 e( Y) q: r" C$ z5 O8 x" u platform_device_unregister(&da850_evm_tl_leds_device);) b6 A5 ?) w6 [/ z
7 T( a$ Q+ B. H6 e printk(KERN_INFO "LED unregister!\n");
e2 }0 C( a/ L x}
% N# M2 R6 s/ d) D8 }; A
& S& T1 F) T: M8 amodule_init(led_platform_init);: }; h0 |, Q! k3 e* w
module_exit(led_platform_exit);
) U' C% t4 c! J6 {, k4 m
) h6 E5 u _" P# ^MODULE_DESCRIPTION("Led platform driver"); d- U9 N- \. R+ _7 o4 W
MODULE_AUTHOR("Tronlong");
/ _6 p- I1 s# r! _$ [+ a. NMODULE_LICENSE("GPL");! J: d4 {* s& l% h. E# x F6 V
G( _2 b: Z7 I6 g b5 h
|
|