|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 u; t8 n! C$ y$ g+ x" C
#include <linux/init.h>
4 v$ W+ W" c V5 W% D/ T#include <linux/module.h>& S" B) x2 \ K! h) ]% z
#include <linux/kernel.h>
6 }* }0 n6 p# f, i. @8 [# q& `5 Q#include <linux/types.h>2 }0 H. M$ w' m: c5 O
#include <linux/gpio.h>( M9 u `, ~% T% M* x; o
#include <linux/leds.h>
- Q# U# ]. [' R) `1 ~#include <linux/platform_device.h>' G2 u; l* ? T+ B; [' s& R$ [2 f
5 ?& x, t" K% o! D4 j+ o, ^
#include <asm/mach-types.h>
; {5 N2 R% k' v! g/ R#include <asm/mach/arch.h>+ F G( U8 _2 y
#include <mach/da8xx.h>4 D0 T$ ~2 x( H0 ?5 p: G9 g
#include <mach/mux.h>
" b6 D. f ?- ]; a8 _/ k* i J6 K' k5 `% h' C$ B: N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 c( A4 D# j1 q3 T$ R8 C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* D6 _ v. b; }: e; P0 G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& K* `* R5 h" M- ]8 M4 V- M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 J( S O$ V. u6 k5 v
R5 G# t% X) S# y/* assign the tl som board LED-GPIOs*/
@* y4 B6 x9 E9 o/ B" h# x2 e& estatic const short da850_evm_tl_user_led_pins[] = {
: W4 j& R' }& ?! ^1 t! H /* These pins are definition at <mach/mux.h> file */; g% O* ^ @$ A2 {* f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- D m& @; t8 t7 p% x) N$ b8 F -1
l) H6 d" @: L5 F};
! a5 H/ i' B* N1 J- j, a5 A4 d. ~$ U* @& |
static struct gpio_led da850_evm_tl_leds[] = {4 _ w# r# u6 U( q
{! W/ X: r1 \% o3 n& ?
.active_low = 0,/ {- Y! m: x$ T+ i* j. E
.gpio = DA850_USER_LED0,
4 X) O) p: a ]6 T: k .name = "user_led0",* B6 n8 k) J' Q! t
.default_trigger = "default-on",
' n2 X/ P! o6 A, v! k3 q },
' u# s( Z% E7 d0 K; P1 G {6 h8 K1 P# f! r- u* e$ ]
.active_low = 0,- p# ~1 x& s7 \2 _4 f5 W# f" k' A
.gpio = DA850_USER_LED1,: T% i8 n4 d& U% B$ {2 t# R
.name = "user_led1",' Z" e6 v5 z3 t" K! k2 ~, _
.default_trigger = "default-on",
3 V/ l) v% o( |" L% c/ c1 |4 j },0 p! Q; D) m( w3 h7 E9 B
{' W6 w* C- `/ y {9 O2 C/ S, s! {
.active_low = 0,$ C& H" y, W* O3 d7 a
.gpio = DA850_USER_LED2,
+ ?- ^& u O$ N .name = "user_led2",$ ^ s8 V) G% ~6 L% Q! m
.default_trigger = "default-on", W1 ?, l4 s4 O( q0 k1 Z3 Z* j
},: p- ~' g V) M. ~* c# C/ f" H
{
4 n" K$ \( j4 S7 ?, E* P3 s .active_low = 0,
- ~1 K9 ~1 j5 r .gpio = DA850_USER_LED3,
* z6 z( E/ M/ d: u1 r0 r .name = "user_led3",
1 q. j6 P" J3 i* ]3 s: z% g! F .default_trigger = "default-on"," x5 R% W' L2 \& X" I
},; \) ?: O W! u0 u% L# {
};# Q" ~0 ~6 ^. ~' J* X# d
+ r: |* }! m* b) ?" m7 I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# Z7 |; q1 Y# e) o
.leds = da850_evm_tl_leds,
; n, G: {, c8 o+ ^& S! e" s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) ~6 R0 w J% f V
};
5 u5 P- w" S. t9 F. V: m& D8 d Z: ?; b, ?
static void led_dev_release(struct device *dev)
9 P! V/ h( F R9 \: O2 g6 b{$ V9 K: f2 E+ i
};! y3 ^, d8 \! Q/ T, A* Y
9 V1 W6 }) ?8 h( h3 Nstatic struct platform_device da850_evm_tl_leds_device = {1 g( b4 `' m1 r+ V% }4 C* s
.name = "leds-gpio",
% t9 U$ D) P( w( E9 I1 ?' v6 ]2 J+ N .id = 1,
9 d; J$ \+ U5 ]. p/ n4 l1 n .dev = {
2 \' T9 g3 e6 S- E) z& L. u1 S .platform_data = &da850_evm_tl_leds_pdata,8 j9 Q; a2 w/ j9 R
.release = led_dev_release,
( U/ a+ |4 x! k- ] }
9 Y$ M9 Q& ^8 s* h# B+ F};
8 _4 k* [, Q% A3 C5 o, c2 l* g+ O( M. C1 X5 t7 L1 H: d3 t
static int __init led_platform_init(void)" }. ^0 p$ H7 ]1 \% P; h
{
8 q* M0 ?% ]% `9 ^ `8 P, v3 ^8 t int ret;
3 e9 t4 L; X1 V0 F2 v#if 00 @$ X; P# u+ N, q( h) J5 X; r& n1 p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- p- b) \- Y' `; a if (ret)
, H3 P" `. ?3 c. m/ m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 F+ K1 A, F8 o! V" a8 H "%d\n", ret);
( X# j9 ?" r$ J: ^#endif
, Y( p9 G$ J5 i+ l7 X t) k, B ret = platform_device_register(&da850_evm_tl_leds_device);( @: ~* u! W: s4 d" g1 R( \9 T. h
if (ret)
* y0 x! E2 i, g7 F3 Q% l pr_warning("Could not register som GPIO expander LEDS");
/ [; ^5 b0 w0 k! E else+ E1 F, H5 Z5 k* k. m' i6 B
printk(KERN_INFO "LED register sucessful!\n");
# _) [/ g" ]; n) z+ @$ Q5 f* h3 R$ l. Y# z1 s/ G( b# _
return ret;: w# n2 n/ Y7 |" P, }7 ~+ c! n
}
8 u3 R6 B$ p j9 ~" {1 F7 I3 n) K/ ^4 k! h( P
static void __exit led_platform_exit(void)
) X! Z9 W$ v! {1 w+ V/ p, I6 B7 |{
1 q( p5 c+ q3 v, L. S platform_device_unregister(&da850_evm_tl_leds_device);& Q1 \+ x, c1 C7 Q; S: n
- w/ y# S$ W9 L% r8 J* M printk(KERN_INFO "LED unregister!\n");! `' F. ~$ r Q; w
}
, @. ^2 [% C( W7 K& I( c
( `- k9 k! @3 w) D: W/ X. z& c' gmodule_init(led_platform_init);2 P' d4 d9 D0 `. g
module_exit(led_platform_exit);, [( _) J" V/ l/ m7 G' U( G
/ M) H6 a: K' g+ TMODULE_DESCRIPTION("Led platform driver");( K$ U7 _3 q( @ @) A
MODULE_AUTHOR("Tronlong");
( F/ U# N7 \3 _0 H; nMODULE_LICENSE("GPL");
" I4 W5 f% g0 Z6 G# f$ y: ^: F6 C: f% r& G3 l
|
|