|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 `; F! _) B7 N( Y$ d( O S
#include <linux/init.h>
# _5 C1 s. b/ @8 o; v#include <linux/module.h>
& ?& V, c: w( l9 _#include <linux/kernel.h>
6 n' G; @9 ] g6 f4 G$ O. J#include <linux/types.h>
) y. X- Z1 U8 o; Q2 a+ f#include <linux/gpio.h>
" ^# T% o1 C2 r0 W* s. ^#include <linux/leds.h>
2 i3 `* o/ p9 O; `% p/ K5 y#include <linux/platform_device.h>
9 b& J$ {0 U+ w3 L6 [4 U B+ w1 s8 K8 A* q2 `4 @
#include <asm/mach-types.h>
: }! F$ I1 Q' \8 E#include <asm/mach/arch.h>5 X9 F2 K( g' ?# O. z/ m
#include <mach/da8xx.h>4 A- S3 Y; ?* s) @7 Y' n5 E# x0 G
#include <mach/mux.h>% r, I3 L& X+ c$ I
2 o, F9 Q, e. n: G: v5 f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 P8 m V# j$ P5 Q, d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) m2 n% v+ Z2 @4 }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 `, h, U5 X) l3 D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% k" k1 P) t# o' o8 p/ l8 a: ^
$ j7 S9 d/ ~' C; \1 _1 {1 ~5 g9 G/* assign the tl som board LED-GPIOs*/( Y$ g* I& R1 I( B0 p
static const short da850_evm_tl_user_led_pins[] = {( i; c, @/ e! ^8 M0 M" w7 M
/* These pins are definition at <mach/mux.h> file */
9 d/ o1 `& b( z- Q/ [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 Y1 ^2 Q# S9 z% r# M. N1 S4 R -1
" P9 k6 K$ [& a2 O0 i' B+ X) \5 X};
2 M! c% ~& \7 ^& Q) ?' y
, q+ j9 q5 x1 w/ F: R6 S, x$ B# ystatic struct gpio_led da850_evm_tl_leds[] = {
7 n, A3 O3 X( {$ A {( g8 T. k, F# b3 U$ `9 p
.active_low = 0,
1 x- B7 ]# P* S6 ^* m .gpio = DA850_USER_LED0,0 l8 C; j7 r: A5 d! C- Q1 Q/ M
.name = "user_led0",
4 B7 g+ X2 ?$ U. m .default_trigger = "default-on",+ n h* K. f3 R2 x# t, o2 V( c* w
},! A) ]- Q$ e: y1 c
{; M' T: j- j2 u$ C7 H0 P R1 B) k
.active_low = 0,6 O8 N+ u2 o$ @0 j. o. A
.gpio = DA850_USER_LED1," Q- ^: m. T; J% f
.name = "user_led1",
1 x/ \5 x+ s% _! B! W5 V .default_trigger = "default-on",8 @9 a, G7 i7 S# f1 r* _
},: d/ h) T4 s' A9 |8 @
{
; D/ R( P f6 a' E .active_low = 0,
9 z* p- Z6 T* }2 U1 R: M .gpio = DA850_USER_LED2,8 ?- V: t! R5 x1 `
.name = "user_led2",
4 M1 n* T' q6 C& ? .default_trigger = "default-on",. \9 y: A( q: p6 k. R+ T
},; t1 J: `7 N8 @
{6 g; _# p1 a1 M1 n
.active_low = 0,4 ?% t+ K2 e- X( e" |
.gpio = DA850_USER_LED3,- s3 N; p6 ?5 ]. d! E6 Y; P
.name = "user_led3",
" `- C/ H; v9 g& T$ O; S* c .default_trigger = "default-on",
$ ?/ m) G2 L. |0 U( t- l },
1 M+ a- |7 ?3 G; _& a7 {' p3 L9 u};
" o3 K& i8 Q1 X3 @! H( b9 _1 Z- j, V. T
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( U9 `' ?; n5 _8 O6 m2 J9 Z .leds = da850_evm_tl_leds,
2 ~. A7 a6 A3 f- t P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 ^/ E, Q/ k; g4 S
};, U, G$ n/ i6 Q% h, }. ^! f# w
2 ^7 [. U; K7 q; r2 zstatic void led_dev_release(struct device *dev)
! T6 }8 C! i6 g6 S: i{
2 C$ E/ R. ?# e};; `+ x7 a( |- s3 P2 v
+ h* l; `0 E- K" J# O% S
static struct platform_device da850_evm_tl_leds_device = {
) O0 K! d, [. s .name = "leds-gpio",4 m- n" K6 n: R; I$ ~
.id = 1,
4 Z5 P( H% w2 m8 b2 b( E e .dev = {1 T6 p" ^5 |, b' Z2 k
.platform_data = &da850_evm_tl_leds_pdata,4 f/ x5 R7 L3 k
.release = led_dev_release, |0 o- s `; b8 M/ O
}
- i% X& |. |7 a7 e! |};& u2 _# O% v% d2 x
. z5 t9 B/ Y) @+ i* B
static int __init led_platform_init(void)
7 k7 q: X( j0 T7 ^& e: G( D{
, y/ @# o" c! _- w int ret;. O; V* v8 k- K* A; f
#if 0& q; [% x4 `+ Y w# C1 i0 L1 C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 U4 D7 ], F; m* t, X3 B if (ret)# t8 M8 W. ?& y$ |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( n8 l8 J0 w- T' P" d "%d\n", ret);$ R5 l' b, @9 K% l6 {7 K& j
#endif0 C( ^0 w6 E! j0 ~0 R! t- N# }, z
ret = platform_device_register(&da850_evm_tl_leds_device);
" I- o) L+ V& G6 }3 X/ Y$ n if (ret)
* z0 O, U! g. |1 u& L5 ]. h1 p) d pr_warning("Could not register som GPIO expander LEDS");
3 ?0 G/ ]2 d1 h- D3 o2 r: W2 ` else; g; F4 w: {0 [
printk(KERN_INFO "LED register sucessful!\n");
3 _7 P1 z8 {( ?) q7 p u; H1 g' _$ ~% {! J
return ret;
2 c0 V1 d9 j% [8 O6 T}) Q! Q5 S, N9 O7 k* F
0 O+ U2 }4 Y- I* wstatic void __exit led_platform_exit(void)! {7 W( z6 r v6 Z/ R
{- l9 J! W. ~! N- {
platform_device_unregister(&da850_evm_tl_leds_device);0 V9 m8 H0 [/ E, G
4 w3 d6 f) J0 E printk(KERN_INFO "LED unregister!\n");+ a" R. }" a6 K% q4 t
}
5 i7 P' b5 W `: u5 P' B8 A/ O$ k1 a
module_init(led_platform_init);
( @8 E. p& y, j* c# B% }8 _/ zmodule_exit(led_platform_exit);
: b' g" a& k% s: v) a* \4 E& R0 ^
MODULE_DESCRIPTION("Led platform driver");2 A( _) G+ L/ U6 d$ W2 ^% P
MODULE_AUTHOR("Tronlong");1 i0 w9 o! C5 H j% A$ U6 d
MODULE_LICENSE("GPL");. X1 [8 w3 M% H3 A& [
P& i% U3 N9 b9 g5 ]
|
|